Filtering forms

branston

Registered User.
Local time
Today, 05:50
Joined
Apr 29, 2009
Messages
372
Hi,

I have a form which I am trying to filter on open using:
DoCmd.OpenForm "FrmAbc", , , "[FieldA] = SomeCriteria")

I have used this many times, so am fairly comfortable with it, however, this time I need to filter where a calculated filed in the form equals some criteria. I have named the field (Field1) and tried using the name in the criteria, but it didnt work. I then tried to put the calculation in the criteria but that didnt work either
e.g.
DoCmd.OpenForm "FrmAbc", , , Left([Abc], 3) = DLookup("[NumberAbc]", "TblAbc")

I know I could put field in the source query as another field, but is there another way around it using vba?

Thank you
 
You need to perform the calculation in your record source, i.e. in the query as an alias field. Then you can filter based on that field.
 

Users who are viewing this thread

Back
Top Bottom