OrderBy

B

Bernie

I have the following expression:

DoCmd.OpenForm "Frm-CN-Archive", , , "[Status]=" & "'" &
Me![SearchValues] & "'", acFormReadOnly

I want to sort on a specific field (Release Date) in
descending order when the form is opened. What is the
expression for this?

Not very experienced with VBA.
Thanks,
Bernie
 
G

Gary Miller

Bernie,

Base your form on a query where you can specify what fields
to sort the records by instead of basing it directly on the
table..

--

Gary Miller
Gary Miller Computer Services
Sisters, OR
________________________
 
F

fredg

Bernie said:
I have the following expression:

DoCmd.OpenForm "Frm-CN-Archive", , , "[Status]=" & "'" &
Me![SearchValues] & "'", acFormReadOnly

I want to sort on a specific field (Release Date) in
descending order when the form is opened. What is the
expression for this?

Not very experienced with VBA.
Thanks,
Bernie

Bernie,
Add a couple of lines of code:

DoCmd.OpenForm "Frm-CN-Archive", , , "[Status]=" & "'" &
Me![SearchValues] & "'", acFormReadOnly

Forms!frm-cn-archive.OrderBy = "[Release Date] Desc"
Forms!frm-cn-archives.OrderByOn = True
 
B

Bernie

It's currently based on a query.
I would like to do it in VB because I plan on adding Case
statements.

i.e. if it's opened with one value, use the Release Date.
If you select another value, use the Effective Date.

I'd prefer not to create multipe queries.
Bernie
-----Original Message-----
Bernie,

Base your form on a query where you can specify what fields
to sort the records by instead of basing it directly on the
table..

--

Gary Miller
Gary Miller Computer Services
Sisters, OR
________________________
Bernie said:
I have the following expression:

DoCmd.OpenForm "Frm-CN-Archive", , , "[Status]=" & "'" &
Me![SearchValues] & "'", acFormReadOnly

I want to sort on a specific field (Release Date) in
descending order when the form is opened. What is the
expression for this?

Not very experienced with VBA.
Thanks,
Bernie


.
 
J

Jim Allensworth

You could use the Open event with code like...

Me.OrderBy = "[Release Date] DESC"
Me.OrderByOn = True

- Jim
 

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