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 wOOdy-Soft on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

If already existing

Status
Not open for further replies.

Xenocide

Programmer
Jan 20, 2005
76
CA
Hi

I'm trying to do a If that would check the database to see if the record that the user wanna create already do so I can tell him

Here's what I have

If
(DLookup("IdEngagementA", "Table850", "IdEngagementA = '" & txt1.Value & "'")) Then

txt1.Value is what the user is gonna enter.
The problem is that either it skip over the if or it tell me that there is type incompatibility

I tried that too

numero = Format(txt1.Value, "00-000000-AA")

then doing the same if but with numero instead of txt1.Value

Why the 00-000000-00? cauz in my database it's the inputmask for IdEngagement and the data type of IdEngagement is text
 
Replace this:
If (DLookup("IdEngagementA", "Table850", "IdEngagementA = '" & txt1.Value & "'")) Then
By this:
If Not IsNull(DLookup("IdEngagementA", "Table850", "IdEngagementA = '" & txt1.Value & "'")) Then
Or this:
If DCount("*", "Table850", "IdEngagementA='" & txt1.Value & "'") Then

Hope This Helps, PH.
Want to get great answers to your Tek-Tips questions? Have a look at FAQ219-2884 or FAQ222-2244
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top