OrderBy

  • Thread starter Thread starter Bernie
  • Start date Start date
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
 
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

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
 
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


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

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

- Jim
 
Back
Top