By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
435,154 Members | 1,024 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 435,154 IT Pros & Developers. It's quick & easy.

comparing values in table to a value keyed into textbox

P: n/a
at moment im trying to compare a value that i type in a text box to values
in the field of a table and if there is a match then there field is updated
like in the code below. but when i try it access is not responding.can any
one help. may be its looping endlessly? i dono. help anyone

Private Sub password_AfterUpdate()
Dim db As DAO.Database
Dim rs As DAO.Recordset

Set db = CurrentDb
Set rs = db.OpenRecordset("SELECT KeywordIN FROM name")

rs.MoveFirst
Do Until rs.EOF
If rs.Fields("KeywordIN").Value = Me.password.Value Then
Me.Presence = "str"
Else
rs.MoveNext
End If
Loop
rs.Close
db.Close
End Sub

Aug 4 '08 #1
Share this Question
Share on Google+
1 Reply


P: n/a
rkc
On Aug 4, 9:48 am, "style101" <u45245@uwewrote:
at moment im trying to compare a value that i type in a text box to values
in the field of a table and if there is a match then there field is updated
like in the code below. but when i try it access is not responding.can any
one help. may be its looping endlessly? i dono. help anyone

Private Sub password_AfterUpdate()

Dim db As DAO.Database
Dim rs As DAO.Recordset

Set db = CurrentDb
Set rs = db.OpenRecordset("SELECT KeywordIN FROM name")

rs.MoveFirst
Do Until rs.EOF
If rs.Fields("KeywordIN").Value = Me.password.Value Then
Me.Presence = "str"
Else
rs.MoveNext
End If
Loop

rs.Close
db.Close

End Sub

I have no idea what you want to happen, but you do have a situation
where the code you posted will loop endlessly the first time

rs.Fields("KeywordIN").Value = Me.password.Value is true.

and it's not the last row in the recordset.

You need to either exit the Do loop when that happens or move
the call to rs.MoveNext outside of the If/Then block so that it is
called each time through the loop.

Aug 4 '08 #2

This discussion thread is closed

Replies have been disabled for this discussion.