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

Opening a table with a sort order

Status
Not open for further replies.

Chucklez

Programmer
Jul 25, 2002
104
US
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 (&quot;strCompanyName like '&quot; + txtCurName + &quot;*'&quot;)
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
 
Would it not be easier to do a query that pulls out all the records with the string in them and order it by employee name? Have fun! :eek:)

Alex Middleton
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top