How to order data on another form?

L

Lee

Hi there,
On clicking a button on Form A, I would like the records
in Form B to be ordered (sorted) in a particular way. I
can't seem to get this to work and I now wonder if it's
possible. On the click event for Form A I've got the
following:

DoCmd.SelectObject acForm, "Form B", False
Form.OrderByOn = True
Form.OrderBy = "CentreNo"

I've tried all sorts of versions of this but nothing
seems to work, any ideas?
Hope you can help.
With thanks,
Lee
 
A

Arvin Meyer

Change the recordsource of form B with a bit of code in a command button
like this:

Forms!FormB.Recordsource = "Select * From tblSomeTable Order By CentreNo;"

Form B will requery to that sort order. Obviously you'll want to first make
sure the form is open, and you may also have a more complex select
statement, but that is the gist of it.
--
Arvin Meyer, MCP, MVP
Microsoft Access
Free Access downloads:
http://www.datastrat.com
http://www.mvps.org/access
 

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