Query results checking in VB

Raddy

Registered User.
Local time
Today, 04:17
Joined
Apr 29, 2010
Messages
34
I want to add a record through a form, but I have to check if the value already exists on the table. The value composed of a client number and account number.

Now, I can run a query in VB and add the record if the query is unsuccessful i.e. no current records match the record I am trying to add, but how do I check in my code if the query is unsuccessful?

Can I achieve the same using a DLOOKUP?
 
Dlookup would probably be a better way to go, maybe in conjunction with an iserror (Does Dlookup pull back an error with no matches? I forget... maybe it doesn't)
 
Does Dlookup pull back an error with no matches?

Yes it does, use DCOUNT instead.

Code:
If Dcount("*", "Table/Query", "Condition") > 0 Then
 ' Record exist

JR
 
Brilliant!
Many thanks!

(I am from an iSeries background so I am familiar with d/b, but we have access to return codes to detremin the results of operations)
 

Users who are viewing this thread

Back
Top Bottom