Filter codes

  • Thread starter Thread starter Rotata
  • Start date Start date
R

Rotata

Ok, I cannot write code on my own.

I need a form to open with certain records excluded and sorted in a certain
order.

I know you can do this on the properties tab, BUT that is way too easy to
mess up.

How can I do this in code?

Form name: frmOutsideEmployment
Field to filter and sort: Crew
Crew to exclude: 999

Thanks!

Rotata
 
You need to do that in the query that is the recordsource of the form. In the
query, sort crew field and then in the criteria for that field, put Not Like
999
 
I would do the sorting in the query that is the record source of the form, as
recommended by Ray. But you can use the WHERE parameter of the OpenForm
method to identify records to include or exclude.

docmd.OpenForm "frm_YourFormName",,,"[Crew] <> 999",,acDialog

I use this all the time, but generally do it like:

docmd.OpenForm "frm_YourFormName",,,"[ID] = " & me.txt_ID,,acDialog

to open a form to a specific record.

--
HTH
Dale

Don''t forget to rate the post if it was helpful!

email address is invalid
Please reply to newsgroup only.
 
Back
Top