Results 1 to 3 of 3
  1. #1
    saltydawg617 is offline Novice
    Windows XP Access 2007
    Join Date
    Jul 2011
    Posts
    4

    Post Using FindFirst code

    I would like to make a function that will check the [SSN] field in the "Members_tbl" table for an existing entry.



    Code:
     
    Public Function FindMember(ByVal FindSSN As String) 
     
    Dim dbMembers As DAO.Database
    Dim dbPath As String
     
    dbPath = CurrentProject.FullName
    Set dbMembers = OpenDatabase(dbPath)
     
    Dim rsSSN As DAO.Recordset
     
    Set rsSSN = dbMembers.OpenRecordset("Members_tbl", dbOpenTable)
    With rsSSN.FindFirst(FindSSN)
    If .NoMatch Then
    MsgBox ("Not Found")
    Else
    MsgBox ("Found " & FindSSN)
    End If
    End With
    End Function

  2. #2
    boblarson is offline --------
    Windows 7 64bit Access 2010 32bit
    Join Date
    Jun 2011
    Posts
    1,272
    You can use DCount:
    Code:
    If DCount("*", "Members_tbl", "[SSNFieldNameHere]=" & Chr(34) & FindSSN & Chr(34))> 0 Then
       ' it was there
    Else
       ' it wasn't
    End If
    I assumed it was text and I didn't know your exact field name so replace with your real one. The "*" in the DCount is on purpose, so leave it as is.

  3. #3
    saltydawg617 is offline Novice
    Windows XP Access 2007
    Join Date
    Jul 2011
    Posts
    4
    Thanks for your help. I'm learning as I go.

Please reply to this thread with any new information or opinions.

Similar Threads

  1. FindFirst with multiple fields in criteria
    By compooper in forum Programming
    Replies: 5
    Last Post: 07-22-2011, 10:29 AM
  2. Replies: 1
    Last Post: 07-19-2011, 05:45 PM
  3. using FindFirst with a Date Criteria (syntax error)
    By ajetrumpet in forum Programming
    Replies: 2
    Last Post: 09-10-2010, 11:01 PM
  4. RST Findfirst date problem
    By ColPat in forum Programming
    Replies: 3
    Last Post: 08-09-2010, 07:28 AM
  5. Recordset Findfirst Problem
    By ColPat in forum Programming
    Replies: 6
    Last Post: 07-22-2010, 04:34 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Other Forums: Microsoft Office Forums