I am attempting to create a form that will allow the user to enter in a string, and all employees with that string in their name will be outputted. I have done this by storing all of the table bookmarks into a array, and enabling a command button that will move from record to record. Now I want to put these employees into some type of alphabetical order.
'opening the table
Set DBS = CurrentDb()
Set rstCustomer = DBS.OpenRecordset("tblARCustomer", dbOpenDynaset, dbSeeChanges)
'finding all employees matching the user inputted string
Private Sub txtCurName_LostFocus()
ReDim varBookMark(1)
X = 0
If txtCurName = "" Then
txtCurClockNumber.SetFocus
Else
rstCustomer.FindFirst ("strCompanyName like '" + txtCurName + "*'"
If rstCustomer.NoMatch Then
MsgBox ("Error: This Employee does" & vbNewLine & _
"Not exist"
txtCurName = ""
txtCurClockNumber.SetFocus
Else
varBookMark(0) = rstCustomer.Bookmark
Do While rstCustomer.EOF <> True
rstCustomer.FindNext ("strCompanyName like '" + txtCurName + "*'"
If rstCustomer.NoMatch <> True Then
X = X + 1
ReDim Preserve varBookMark(X + 1)
varBookMark(X) = rstCustomer.Bookmark
cmdFindNext.Visible = True
txtCurRecord.Visible = True
txtTotRecord.Visible = True
lblOF.Visible = True
txtCurRecord = 1
txtTotRecord = X + 1
Else
rstCustomer.Bookmark = varBookMark(0)
Exit Do
End If
Loop
rstCustomer.Bookmark = varBookMark(0)
txtCurName = rstCustomer!strCompanyName
txtCurBadgeNumber = rstCustomer!strCustomerID
txtCurClockNumber = rstCustomer!strClockNumber
txtSSN = rstCustomer!strTaxNumber
End If
End If
End Sub
Then by pressing cmdFindNext, the user can move between records.
How do I sort these records into a alphabetical order? Im assuming an orderby function, but am not sure how it works.
Thanks for the help,
-Chuck
'opening the table
Set DBS = CurrentDb()
Set rstCustomer = DBS.OpenRecordset("tblARCustomer", dbOpenDynaset, dbSeeChanges)
'finding all employees matching the user inputted string
Private Sub txtCurName_LostFocus()
ReDim varBookMark(1)
X = 0
If txtCurName = "" Then
txtCurClockNumber.SetFocus
Else
rstCustomer.FindFirst ("strCompanyName like '" + txtCurName + "*'"
If rstCustomer.NoMatch Then
MsgBox ("Error: This Employee does" & vbNewLine & _
"Not exist"
txtCurName = ""
txtCurClockNumber.SetFocus
Else
varBookMark(0) = rstCustomer.Bookmark
Do While rstCustomer.EOF <> True
rstCustomer.FindNext ("strCompanyName like '" + txtCurName + "*'"
If rstCustomer.NoMatch <> True Then
X = X + 1
ReDim Preserve varBookMark(X + 1)
varBookMark(X) = rstCustomer.Bookmark
cmdFindNext.Visible = True
txtCurRecord.Visible = True
txtTotRecord.Visible = True
lblOF.Visible = True
txtCurRecord = 1
txtTotRecord = X + 1
Else
rstCustomer.Bookmark = varBookMark(0)
Exit Do
End If
Loop
rstCustomer.Bookmark = varBookMark(0)
txtCurName = rstCustomer!strCompanyName
txtCurBadgeNumber = rstCustomer!strCustomerID
txtCurClockNumber = rstCustomer!strClockNumber
txtSSN = rstCustomer!strTaxNumber
End If
End If
End Sub
Then by pressing cmdFindNext, the user can move between records.
How do I sort these records into a alphabetical order? Im assuming an orderby function, but am not sure how it works.
Thanks for the help,
-Chuck