sql select

ggreg

Registered User.
Local time
Today, 19:33
Joined
Aug 12, 2002
Messages
66
I have a form with a textbox and a button,

when i type a value in the textbox and click the button I want it to check a record in a table for
a value if it is then, I will do step A if it is not there then I am going to do step B

what is wrong with the code below place code in on click event of button:

Dim strlogon As String
strlogon = "SELECT SM_DBA_PC_USER_DEF.USER_ID FROM SM_DBA_PC_USER_DEF WHERE (((SM_DBA_PC_USER_DEF.USER_ID)=Forms!frmlogin!Login));"

(If strlogon = "ishan"....I was putting this in just to test if I was getting a good response becasue if I type in ishan into the text box ishan is in my table I would expect this to come back with testgood but its not doing that what is wrong with my code????? ) Then
MsgBox ("testgood")................this will be step A
'Else
MsgBox ("testbad")............... this will be step B
'End If
 
Just check what u are sending in where contional ..frmlogin!login
 
??

You can't use SQL directly like that. Here's one alternative:

strlogon = DLookup("USER_ID", "SM_DBA_PC_USER_DEF", "USER_ID = '" & Forms!frmlogin!Login & "'")
 

Users who are viewing this thread

Back
Top Bottom