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

Compare data in form field to stored table data 1

Status
Not open for further replies.

dlackey

Technical User
Jan 1, 2005
6
0
0
US
Hello,

I have a database that when started, "Login" form opens and users select their username from a combobox and then type their password in the next field, and if both match with stored table data then login form closes and another form opens called "Main".

This new form has a command button called "Change Password" and when users click it a popup form opens called "Change Password". It contains three unbound fields, "Current Password" "New Password" "Confirm Password". Users type in their current pword, a new pword and confirm their new pword. Next they click OK to update.

Now here's the problem...
when users click OK to update pword, I want to compare the current pword with what is stored in the table "Users". It will only compare with first record in table, not compare all records.

How can I get it to compare to all pwords stored in table and not just first one?

Any help would be appreciated...
 
dlackey,

I just built a mdb as table1 with a field named field1. I tied the data to form1 with an unbound box named text2.

The following code says "bingo" when there is a hit and somethiing else with no hit. There are more sophisticated ways but try this.


Private Sub Text2_DblClick(Cancel As Integer)
Dim rs As DAO.Recordset, gotit As Boolean, chk As String
Set rs = Me.RecordsetClone
rs.MoveLast
rs.MoveFirst
chk = "Field1 = '" & Me.Text2 & "'"

rs.FindFirst chk

If rs.NoMatch Then MsgBox "Not there" Else MsgBox "bingo"

End Sub

rollie
 
Take a look at the DLookUp function:
If Not IsNull(DLookUp("pword", "Users", "pword='" & [Current Password] & "'")) Then
' Update Users.pword
...

Hope This Helps, PH.
Want to get great answers to your Tek-Tips questions? Have a look at FAQ219-2884 or FAQ222-2244
 
Rollie,

Tried your suggestion/code and got:
Run-time error '7951': You entered an expression that has an invalid reference to the RecordSetClone proerty

I did change chk = "Field1 = '" & Me.Text2 & "'" to my corresponding field names

PHV,

Tried your suggestion/code and results are:
"Change Password" form closes but password is not updated when close database and try to login with new password

Any further ideas?
Thanks
 
but password is not updated
How you tried it ?
A starting point:
DoCmd.RunSQL "UPDATE Users SET pword='" & [New Password] & "' WHERE pword='" & [Current Password] & "'"


Hope This Helps, PH.
Want to get great answers to your Tek-Tips questions? Have a look at FAQ219-2884 or FAQ222-2244
 
PHV,

Got it working now thanks to your suggestion!

Thanks for all the help!

dlackey
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top