Page 1 of 2 12 LastLast
Results 1 to 15 of 16
  1. #1
    Star Lounger
    Join Date
    Jun 2001
    Location
    Bethlehem, Pennsylvania, USA
    Posts
    67
    Thanks
    0
    Thanked 0 Times in 0 Posts

    FindFirst Troubles (2k)

    Could anyone help me with this problem. I am attempting to use the FindFirst command but I always get the following error.
    Runtime error

  2. #2
    Platinum Lounger
    Join Date
    Dec 2001
    Location
    Melbourne, Australia
    Posts
    4,594
    Thanks
    0
    Thanked 27 Times in 27 Posts

    Re: FindFirst Troubles (2k)

    Try changeing the startement

    r.FindFirst ("F3 =") & "DAA"

    to

    r.FindFirst "F3 =" & "DAA"

    HTH
    Pat <img src=/S/cheers.gif border=0 alt=cheers width=30 height=16>

  3. #3
    Star Lounger
    Join Date
    Jun 2001
    Location
    Bethlehem, Pennsylvania, USA
    Posts
    67
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: FindFirst Troubles (2k)

    Hey Pat,
    I just tried that and it didn't work.
    Same error message
    <img src=/S/brickwall.gif border=0 alt=brickwall width=25 height=15>

  4. #4
    Platinum Lounger
    Join Date
    Dec 2001
    Location
    Melbourne, Australia
    Posts
    4,594
    Thanks
    0
    Thanked 27 Times in 27 Posts

    Re: FindFirst Troubles (2k)

    Is F3 a field in that table (I know, an obvious question)?
    I notice that you didn't put DAO. prior to database in the Dim statement.
    If that doesn't work, then post the database if it's Access 2000 or Access97.
    Pat <img src=/S/cheers.gif border=0 alt=cheers width=30 height=16>

  5. #5
    3 Star Lounger
    Join Date
    Dec 2001
    Location
    Nevada, USA
    Posts
    207
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: FindFirst Troubles (2k)

    As an alternative, try:

    r.FindFirst "F3 = ""DAA"""

    This assumes that F3 is a text field. This code also assumes that DAA is a constant.
    Carol W.

  6. #6
    Platinum Lounger
    Join Date
    Dec 2001
    Location
    Melbourne, Australia
    Posts
    4,594
    Thanks
    0
    Thanked 27 Times in 27 Posts

    Re: FindFirst Troubles (2k)

    Or better still,

    r.FindFirst "F3 = 'DAA' "

    Pat <img src=/S/cheers.gif border=0 alt=cheers width=30 height=16>

  7. #7
    Star Lounger
    Join Date
    Jun 2001
    Location
    Bethlehem, Pennsylvania, USA
    Posts
    67
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: FindFirst Troubles (2k)

    F3 is a text field in a table. I tried putting a DAO in front of the database DIM statement. No Luck
    Here is the database. It is just a testing database to see how I can get this problem solved.
    I had to zip it up since it was just over the 100k limit
    Thanks for your help.
    Attached Files Attached Files

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

    Re: FindFirst Troubles (2k)

    Two things: first, change your reference to DAO 3.6 if you're using A2k; and second, add the type argument to your open recordset.

    <pre>Private Sub Command3_Click()
    Dim d As DAO.Database

    Dim r As DAO.Recordset

    Set d = CurrentDb
    Set r = d.OpenRecordset("table1", dbOpenDynaset)
    r.FindFirst ("F3 =") & "'DAA'"

    Me.Text2 = r!F2

    End Sub</pre>

    Charlotte

  9. #9
    Star Lounger
    Join Date
    Jun 2001
    Location
    Bethlehem, Pennsylvania, USA
    Posts
    67
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: FindFirst Troubles (2k)

    That works. I am running Access97 in the office. Can I use the same code for A97?

    Thank you Charlotte

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

    Re: FindFirst Troubles (2k)

    The code is the same. It's only the DAO reference that changes between versions. But if you're using A97, why did the subject like say 2k?
    Charlotte

  11. #11
    Platinum Lounger
    Join Date
    Dec 2001
    Location
    Melbourne, Australia
    Posts
    4,594
    Thanks
    0
    Thanked 27 Times in 27 Posts

    Re: FindFirst Troubles (2k)

    She's good <img src=/S/bravo.gif border=0 alt=bravo width=16 height=30>, isn't she !!

    Pat <img src=/S/cheers.gif border=0 alt=cheers width=30 height=16>

  12. #12
    Star Lounger
    Join Date
    Jun 2001
    Location
    Bethlehem, Pennsylvania, USA
    Posts
    67
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: FindFirst Troubles (2k)

    I am working with Access 2k at home. It was just for my general knowledge to see if this would be the same between versions.

    thanks again <img src=/S/salute.gif border=0 alt=salute width=15 height=20>

  13. #13
    Star Lounger
    Join Date
    Jun 2001
    Location
    Bethlehem, Pennsylvania, USA
    Posts
    67
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: FindFirst Troubles (2k)

    Hey Pat,

    Thanks for all your help <img src=/S/cheers.gif border=0 alt=cheers width=30 height=16>

  14. #14
    2 Star Lounger
    Join Date
    Oct 2002
    Posts
    114
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: FindFirst Troubles (2k)

    Charlotte,

    I've been away from Access for about three years and have managed to forget most everything I knew. [img]/forums/images/smilies/sad.gif[/img]

    I am having a problem with A2K / WinXP in that Access won't let me use .FindFirst; Additionally, when I attempt to use the "DAO." specifier, the VB editor errors. Here's my snippet:

    (1) Dim intSelectedBuildID As Integer ' global to module
    (2) Private Sub fnGetSelectedParentBuildID()
    (3) Dim rstFind As DAO.Recordset
    (4) If (intSelectedBuildID >= 0) Then
    (5) Set rstFind = CurrentDb.OpenRecordset("test", dbOpenDynaset)
    (6) With rstFind
    (7) .MoveLast
    (8) .findfirst "intBuildID = " & intSelectedBuildID
    (9) If .nomatch Then
    (10) MsgBox "No record found with BuildID '" & intSelectedBuildID & "'"
    (11) Else
    (12) intParentBuildID = rst.Fields("intParentBuildID")
    (13) MsgBox "Found intParentBuildID of '" & intParentBuildID & "'"
    (14) End If
    (15) .Close
    (16) End With
    (17) End If
    (18) End Sub

    When I try to compile it this way, Access highlights line (3) (except "DIM") with the following error:

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

    Re: FindFirst Troubles (2k)

    You *must* set a reference to DAO 3.6 or Access will continue to spit up on you. Access 2000 defaults to the ADO object model. The fact that Access is choking on your Dim rstFind As DAO.Recordset says that you forgot to set the reference. Go into the VB Editor and select References from the Tools menu. You'll have to scroll down a ways to find the Microsoft DAO 3.6 Object Model, but that's the one you need to support DAO code.

    You should also declare a DAO.Database object instead of using "Set rstFind = CurrentDb.OpenRecordset("test", dbOpenDynaset)". I can never remember the arguments why because I never used that construction, but I keep running across them in various Access lists. I seem to recall that using the CurrentDb object that way doesn't return a persistent object the way setting a database object variable to the result of the CurrentDb() function does. <img src=/S/scratch.gif border=0 alt=scratch width=25 height=29>

    Anyhow, until you set the DAO reference and get in the habit of specifying DAO.Whatever when you declare objects, you'll keep getting errors.
    Charlotte

Page 1 of 2 12 LastLast

Posting Permissions

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