Evaluate a condition

gear

Registered User.
Local time
Yesterday, 22:20
Joined
Mar 10, 2007
Messages
112
Please have a look at the following code (I am not good at VBA or SQL).

Me.[txtBox] = DLookup(“[SNum]”, “[Table1]”, “[RecID])
If Me.txtBox =>2 Then
Condition if true
Else
Condition if false
End If

I type a value in my [txtBox], a number. I want to evaluate if the typed value meets the condition or not. [SNum] is serially numbered and [RecID] is autonumber Primary Key. The above code is not working. How do I achieve this? Please help.
 
Hi
You have to put a condition in the third part of the DLookup, or else leave it out altogether. If you leave it out then the look will test the value of SNum. But you might be better to dim a variable rather than using a textbox -

Code:
lngTest = DLookup(“[SNum]”, “[Table1]”)
If lngTest =>2 Then
Condition if true
Else
Condition if false
End If

HTH
 
gear,

Code:
If DCount("[RecID]", "[Table1]", “[RecID] = " & Me.txtBox) > 0 Then
   Condition if true <-- Autonumber in Me.txtBox exists
Else
   Condition if false <-- Autonumber in Me.txtBox doesn't exists
End If

Wayne
 

Users who are viewing this thread

Back
Top Bottom