comparing values in table to a value keyed into textbox

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • style101

    comparing values in table to a value keyed into textbox

    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_AfterU pdate()


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

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

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


    rs.Close
    db.Close


    End Sub

  • rkc

    #2
    Re: comparing values in table to a value keyed into textbox

    On Aug 4, 9:48 am, "style101" <u45245@uwewrot e:
    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_AfterU pdate()
    >
    Dim db As DAO.Database
    Dim rs As DAO.Recordset
    >
    Set db = CurrentDb
    Set rs = db.OpenRecordse t("SELECT KeywordIN FROM name")
    >
    rs.MoveFirst
    Do Until rs.EOF
    If rs.Fields("Keyw ordIN").Value = Me.password.Val ue 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("Keyw ordIN").Value = Me.password.Val ue 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.

    Comment

    Working...