stLinkCriteria

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

I need to have a button open the next form with two parts to the
linkcriteria. I have two combo boxes that are being used to select the year
and the model.

How do I code two or more sets of criteria for a docmd.openform?

Thanks
 
DoCmd.OpenForm "FormName", , , "[Field1]=" & _
Me.ComboBox1.Value & " And [Field2]=" & _
Me.ComboBox2.Value
 
I need to have a button open the next form with two parts to the
linkcriteria. I have two combo boxes that are being used to select the year
and the model.

How do I code two or more sets of criteria for a docmd.openform?

Thanks

The criteria string needs to be a valid SQL Query WHERE clause,
without the word WHERE. It can be almost arbitrarily complex (up to
64KBytes if I recall aright). One way to create it would be to use the
query grid to create a Query which retrieves the values that you want,
go to SQL view, and use its WHERE clause as a model. It will probably
end up something like

stLinkCriteria = "[YearField] = " & Me!txtYear & " AND [Model] = '" _
& Me!cboModel & "'"

This will generate a string resembling

[YearField] = 1992 AND Model = 'Camry'

if you're looking for my car.

John W. Vinson[MVP]
 
Back
Top