• Find function (VB6)

    Author
    Topic
    #358723

    Ok this is starting to get to me. I am trying to set up some text boxes that will basically run a query on the fly. Anyway I keep getting an error that says Sub or Function no defined, I am not exactly sure as to what I am missing in my code. Her is my code.

    Private Sub cmdFindNext_Click()

    Dim strQry As String
    Dim rsAsk As Recordset
    Dim dbMe As DAO.Database

    Set dbMe = currentdb()

    strQry = “SELECT * FROM TotalTimeOff WHERE [TotalTimeOff]![TMfirstname] = ” ‘” & QMFN & “‘” AND [TotalTimeOff]![TMlastname] = “‘” & QMLN & “‘””

    Set rsAsk = dbMe.OpenRecordset(strQry)

    rsAsk.MoveFirst
    If Not rsAsk.EOF Then
    rsAsk.MoveNext
    End If

    End Sub

    Attatched is the picture of the error and then the lines that are highlighted in result of. Any help is appreciated.

    Viewing 0 reply threads
    Author
    Replies
    • #535844

      Maybe it’s my machine, but I don’t see anything in your attachment. shrug One thing I would point out, though. If you have an ADO reference set in VB 6, you need to declare your recordset variable as DAO.Recordset, the same way you did the database variable. ADO also has a recordset object but its properties and methods are different, and that can cause unexpected error messages.

      • #535852

        I think it’s your machine because I can open it and see everything in it fine. I will try what you suggested, and post back.

        • #535878

          I can see it on my work machine, but apparently the dialup connection at home is too slow. It appears to be choking on CurrentDB which is not a valid function or object in Visual Basic and will error out unless you have a reference set to the Access Object library. But even if you have a reference set, you don’t have a connection to a database to make CurrentDB work as it does from within Access. In VB, you have to use the OpenDatabase method to populate your DAO database object. Look it up in VB help.

    Viewing 0 reply threads
    Reply To: Find function (VB6)

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

    Your information: