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

    Home » Forums » AskWoody support » Productivity software by function » MS Access and database help » Object Variable or With Block Variable not set (Access 2k)

    Author
    Topic
    #401353

    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

    Viewing 0 reply threads
    Author
    Replies
    • #789972

      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

      • #789973

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

        Thanks Hans

      • #789974

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

        Thanks Hans

    Viewing 0 reply threads
    Reply To: Object Variable or With Block Variable not set (Access 2k)

    You can use BBCodes to format your content.
    Your account can't use all available BBCodes, they will be stripped before saving.

    Your information: