Sort continous form by 2 colums

J

Jane

Hello everyone

Is it possible to sort a continous form by more than one field

I have this

Private Sub SortAZ_Name_Click()
Me.OrderBy = "Surname"
End Sub

But I would like something like this

Private Sub SortAZ_Name_Click()
Me.OrderBy = "Surname" and 1stname
End Sub

Is this possible

Thank you for your help if you can offer any tips

Jane
 
S

Steve

From the Help file ...........
The OrderBy property is a string expression that is the name of the field or
fields on which you want to sort records. When you use more than one field
name, separate the names with a comma (,).
When you set the OrderBy property by entering one or more field names, the
records are sorted in ascending order. Similarly, Visual Basic sorts these
fields in ascending order by default.
If you want to sort records in descending order, type DESC at the end of the
string expression. For example, to sort customer records in descending order
by contact name, set the OrderBy property to "ContactName DESC".

So you need ...
Me.OrderBy = "Surname", "1stname"

This will sort both fields Ascending.

Steve
(e-mail address removed)
 
D

Douglas J. Steele

Private Sub SortAZ_Name_Click()
Me.OrderBy = "Surname,1stname"
End Sub
 
J

John W. Vinson

Hello everyone

Is it possible to sort a continous form by more than one field

I have this

Private Sub SortAZ_Name_Click()
Me.OrderBy = "Surname"
End Sub

But I would like something like this

Private Sub SortAZ_Name_Click()
Me.OrderBy = "Surname" and 1stname
End Sub

Is this possible

Thank you for your help if you can offer any tips

Jane

Sure. The OrderBy property can consist of one to ten (or maybe more)
fieldnames, separated by commas:

Me.OrderBy = "[Surname],[1stName],[MiddleInitial],[Suffix]"
 
J

Jane

Dear Steve, Douglas and John

Thank you for your help. It works really well now.

Jane
 
M

matthew

Jane said:
Hello everyone

Is it possible to sort a continous form by more than one field

I have this

Private Sub SortAZ_Name_Click()
Me.OrderBy = "Surname"
End Sub

But I would like something like this

Private Sub SortAZ_Name_Click()
Me.OrderBy = "Surname" and 1stname
End Sub

Is this possible

Thank you for your help if you can offer any tips

Jane
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top