Two-way Sub-form

N

Nancy

I'm trying to add a sub-form to a switchboard form that
displays a list of names in alphabetical order by first
name or by last name, depending on which command button
is chosen. I have the queries built for first or last
name order. How can I make alternating queries appear in
the same space depending on which button is clicked?
 
M

Mike Painter

Nancy said:
I'm trying to add a sub-form to a switchboard form that
displays a list of names in alphabetical order by first
name or by last name, depending on which command button
is chosen. I have the queries built for first or last
name order. How can I make alternating queries appear in
the same space depending on which button is clicked?
I assume you are using a subform.
Setting the recordset to the appropriate query is one way.
Using a tabbed form with a different subform would be another.
Making one form visible and another invisible is a third.

It depends on what the client wants but I always make an effort to have them
learn to right click and sort on the column they want rather than use
buttons. This works everywhere and gives them more freedom.
 
J

John Vinson

I'm trying to add a sub-form to a switchboard form that
displays a list of names in alphabetical order by first
name or by last name, depending on which command button
is chosen. I have the queries built for first or last
name order. How can I make alternating queries appear in
the same space depending on which button is clicked?

One way is to change the subform's OrderBy property in the button's
click event: something like

Private Sub cmdSortLast_Click()
Me!subformname.Form.OrderBy = "[LastName]"
Me!subformname.Form.OrderByOn = True
End Sub

Or use the same event to change the subform's Recordsource property if
the queries have more than just the one change.
 

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