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

Checking for multiple occurences in a table

Status
Not open for further replies.

Chucklez

Programmer
Jul 25, 2002
104
US
I am creating a form that allows the user to enter a employees clock number, and have all the employees information to be returned to them. I also need to allow the user to enter the employees name, with the same result.

The problem with entering in a employees name is that there may be multiple employees with the same name (John Smith for example).

I am wanting to allow the user to enter in the employees name, and if multiple instances are found, display a command button that will allow the user to move to the next employee with that name. This is the code I have so far:

Private Sub txtCurName_LostFocus()
Dim var As Variant

If txtCurName = "" Then
txtCurClockNumber.SetFocus
Else
rstCustomer.FindFirst ("strCompanyName = '" + txtCurName + "'")
If rstCustomer.NoMatch Then
MsgBox ("Error: This Employee does" & vbNewLine & _
"Not exist")
txtCurName = ""
txtCurClockNumber.SetFocus
Else
txtCurName = rstCustomer!strCompanyName
txtCurBadgeNumber = rstCustomer!strCustomerID
txtCurClockNumber = rstCustomer!strClockNumber
txtSSN = rstCustomer!strTaxNumber
End If
End If

var = rstCustomer.Bookmark
rstCustomer.MoveNext
rstCustomer.FindNext ("strCompanyName = '" + txtCurName + "'")
If rstCustomer.EOF = True Then
rstCustomer.Bookmark = var
Else
cmdFindNext.Visible = True
rstCustomer.Bookmark = var
End If
End Sub

When I run this code, it displays the cmdFindNext button, but there are NO instances of this test employee in the table. It appears as if it is finding the first employee again.

Is there something wrong in my logic?
Thanks for the help
-Chuck
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top