Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations derfloh on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Check for Record with Access 2

Status
Not open for further replies.

jeffshex

Technical User
Jun 30, 2005
208
US
I need someone to point me in the right direction here.
I want to have some code fire in a before update event that looks at a table to see if a specific ID already exists.
I will probably have it grab the ID from the other form that's open.
How do I go about this? Is it a rows returned kind of thing or a DLookup?

Ideas?
 
If any instance of the ID is sufficient, then DlookUp should suit.
 
I have this working, but it seems to never roll over to the else statement, whether the condition is satisfied or not.
Code:
If IsNull(DLookup("[ComponentEnrolled]", "tblComponents", "[SS#] = " & Me.[SS#])) Then
        MsgBox "Advise Component Here", vbOKOnly, "Warning!"
    Else
        MsgBox "This person already exists.", vbOKOnly, "Test"
    End If

Is this just how IsNull works or what?
What a bugger.
 
What about this ?
Code:
If IsNull(DLookup("[ComponentEnrolled]", "tblComponents", "[SS#] = [!]'[/!]" & Me.[SS#] [!]& "'"[/!])) Then
    MsgBox "Advise Component Here", vbOKOnly, "Warning!"
Else
    MsgBox "This person already exists.", vbOKOnly, "Test"
End If

Hope This Helps, PH.
FAQ219-2884
FAQ181-2886
 
That did it!
What exactly did adding that in do?
Was the previous way not passing the criteria properly?
 
I guessed that SS# was defined as text in tblComponents and thus showed you how to deal with non numeric criteria.

Hope This Helps, PH.
FAQ219-2884
FAQ181-2886
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top