Results 1 to 3 of 3
  1. #1
    3 Star Lounger
    Join Date
    Oct 2001
    Location
    Newport, Gwent, Wales
    Posts
    257
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Object Variable or With Block Variable not set (Access 2k)

    Dear All

    The following code is giving me the error stated 'Object Variable or With Block Variable not set'. Except the thing is set........

    Dim DbS As DAO.Database
    Dim strSQL As String
    Dim RsT As DAO.Recordset
    Dim strInput As String
    Dim stDocName As String
    Dim qrydefRework As DAO.QueryDef
    Dim strQryDef As String

    strQryDef = Forms!gireturnsnotectlfrm!RejectNoteNumber
    qrydefRework.Parameters("[Forms]![GIReturnsNoteCtlFrm]![RejectNoteNumber]") = Me.RejectNoteNumber 'This line errors out
    Set qrydefRework = DbS.QueryDefs("ReworkQrydef")

    When I go to debug the VBA editor shows the correct value is being reported in the 'Me.rejectNoteNumber' . The thing that is absolutely driving me up the wall is that I've used this code, including the variable names, in another event on a different form (I've checked they're both private functions).

    I know it's going to be something simple and stupid that I've missed, but after a couple of hours with the books I give up!!!!

    Please HELP!!

    Thanks

    Ian

  2. #2
    Plutonium Lounger
    Join Date
    Mar 2002
    Posts
    84,353
    Thanks
    0
    Thanked 29 Times in 29 Posts

    Re: Object Variable or With Block Variable not set (Access 2k)

    Your lines are in the wrong order: you use qrydefRework before setting it. Moreover, you haven't set DbS yet. That should go first.

    Set DbS = CurrentDb
    strQryDef = Forms!gireturnsnotectlfrm!RejectNoteNumber ' what does this do?
    Set qrydefRework = DbS.QueryDefs("ReworkQrydef")
    qrydefRework.Parameters("[Forms]![GIReturnsNoteCtlFrm]![RejectNoteNumber]") = Me.RejectNoteNumber

  3. #3
    3 Star Lounger
    Join Date
    Oct 2001
    Location
    Newport, Gwent, Wales
    Posts
    257
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Object Variable or With Block Variable not set (Access 2k)

    This is one of those times I just shouldn't have been allowed loose with a computer.

    Thanks Hans

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •