View Full Version : sorting in a form


capri
05-31-2001, 11:03 AM
Hi,

I have some records that can be sorted in several ways. I gave them UID (Universal identifier) numbers as the primary key in order to sort them chronilogically. Another method of sorting would be by reference number. I can sort the field by reference number in the table, but the input form still shows the records sorted by UID.

I did a search on this forum and found some code

Private Sub CmdSort_Click()
Me.OrderBy = "Field"
Me.OrderByOn = True
End Sub

that I just substituted "Field" with "Reference" However, this bit does not seem to work. My records are still sorted by UID. I need to have them sorted by Reference number in order to see if there are some duplicate items.

Can anyone give me a suggestion on how I can get the records sorted properly in my form?

Thanks

DES
05-31-2001, 11:46 AM
Your form is probably based on a table which does not allow for easy sorting. Instead make a query based on the table. The query will allow you to set the sort order you want.

Then go back to your original form and change it's data source to be the query instead of the table. The query's sort order will be passed to the form.