OrderBy Property

G

Guest

Is it possible to set the OrderBy property for a form based on a query during
the Form Open event? There will be 3 choices for how the user wants to view
the records and I'd rather not create 3 queries and 3 forms to handle the
choices. I'm looking for an example in code of how this might be done.

I tried this:
Me.OrderBy = Me.txtAddress
Me.OrderByOn = True

But it didn't seem to work. It prompted me for a value.

Thanks in advance,
 
F

fredg

Is it possible to set the OrderBy property for a form based on a query during
the Form Open event? There will be 3 choices for how the user wants to view
the records and I'd rather not create 3 queries and 3 forms to handle the
choices. I'm looking for an example in code of how this might be done.

I tried this:
Me.OrderBy = Me.txtAddress
Me.OrderByOn = True

But it didn't seem to work. It prompted me for a value.

Thanks in advance,

OrderBy must be a string.

Me.OrderBy = "txtAddress"
Me.OrderByOn = True
 
G

Guest

Fred, thanks for the input. When I tried this it still didn't work because
txtAddress is the name of a text box. I wound up changing the OrderBy string
to contain the actual name of the field instead of the name of the text box
bound to the field. But of course from my original question, there was
really no way you would have known this was the case because txtAddress
"could" have been the name of the field.
 

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