Results 1 to 4 of 4
  1. #1
    2 Star Lounger
    Join Date
    May 2002
    Location
    USA
    Posts
    190
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Find function (VB6)

    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.
    Attached Files Attached Files

  2. #2
    Plutonium Lounger
    Join Date
    Dec 2000
    Location
    Sacramento, California, USA
    Posts
    16,775
    Thanks
    0
    Thanked 1 Time in 1 Post

    Re: Find function (VB6)

    Maybe it's my machine, but I don't see anything in your attachment. <img src=/S/shrug.gif border=0 alt=shrug width=39 height=15> 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.
    Charlotte

  3. #3
    2 Star Lounger
    Join Date
    May 2002
    Location
    USA
    Posts
    190
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Find function (VB6)

    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.

  4. #4
    Plutonium Lounger
    Join Date
    Dec 2000
    Location
    Sacramento, California, USA
    Posts
    16,775
    Thanks
    0
    Thanked 1 Time in 1 Post

    Re: Find function (VB6)

    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.
    Charlotte

Posting Permissions

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