Open form using VBA where criteria = 2 different requirments

jjake

Registered User.
Local time
Today, 07:00
Joined
Oct 8, 2015
Messages
291
Hello i have a search form to open up a continuous form.

my search form has 1 combo box. cboplantnum.
my continuous form has 2 fields [PlantNum], [cbosubUtilityType]

I would like to filter the form using a WHERE function.

I would like to filter by cboplantnum on the search form AND also filter by the value of 1 for cboSubUtilityType which is on the continuous form.

the value of 1 is the first record in my combobox from tblSubUtilityType.
 
I tried the following code but got an error. Run time error 13 Type Mismatch.

Code:
DoCmd.OpenForm "frmEquipmentList", , , "PlantNum = " & Me.cboPlantNum And "cboUtilitySubType = " & 1
 
The concatenation is off, and there's no need to concatenate a fixed value. Try:

DoCmd.OpenForm "frmEquipmentList", , , "PlantNum = " & Me.Combo20 & " And cboUtilitySubType = 1"

Is cboUtilitySubType really the name of a field in the data?
 
The concatenation is off, and there's no need to concatenate a fixed value. Try:

DoCmd.OpenForm "frmEquipmentList", , , "PlantNum = " & Me.Combo20 & " And cboUtilitySubType = 1"

Is cboUtilitySubType really the name of a field in the data?

I tried this but it asks me to enter a parameter value for cboUtilitySubType.

The field is the correct name but it does not appear on the first form. Only the second.
 
Never mind I got it figured out by reading more into what you said. cboUtilitySubType was the name of the field and not the data. The data was UtilitySubType. That fixed it thanks,
 
The parameter prompt is Access telling you it can't find something. Double check the spelling of the field, and ensure it is included in the record source of frmEquipmentList. Normally a field wouldn't be prefixed with "cbo", a combo box would.
 
Ah, you got it sorted while I was typing. Glad it worked for you.
 

Users who are viewing this thread

Back
Top Bottom