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

Comparing text box information to a table

Status
Not open for further replies.

DSMCBackup

Technical User
Apr 24, 2003
190
GB
Hi,

I was wondering if there was a way of comparing a string entered in an unbound text box against a table of data?

Two text boxes on a login screen, username and password. Firstly validate against a table of known users that the username exists, and the given password is valid for that username.

Only thing i could see close was DLookup but this didnt seem to allow comparison to non-tabled data in the criterion part?

I'm fairly novice when it comes to Access2003 and VBA, so any help here would be useful.

Cheers.
 
It seems to me you could use a select statement to try and pull out the info.
Code:
Function checkstring()

Dim rst as DAO.Recordset
Dim strSQL as String

strSQL = "Select tblN.User, tblN.Password From tblN Where tblN.User = '" & Forms!FName!TextboxName & "' and tblN.Password = '" & Forms!FName!TextboxName2 & "'"
Set rst = CurrentDb.OpenRecordset (strSQL, dbOpenDynaset)
If rst.EOF or rst.BOF Then
MsgBox "No user or Password matches"
Else
Do something here
End If
Set rst = Nothing
End Function

Paul
 
Hi,

"Dim rst As DAO.Recordset" - User defined type not defined?

 
You need to install the DAO library. Open a module, and on the tool bar go to Tools/References. You will see some libraries checked at the top of the list. If you scroll down, you will see one for
Microsoft DAO 3.6 Object library. Check the box next to it, and then save the change. That should do it for you.

Paul
 
You may also simply consider the DLookUp function.

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

Part and Inventory Search

Sponsor

Back
Top