VBA Where condition when the field itself is a variable

rodski

New member
Local time
Today, 10:32
Joined
Feb 4, 2013
Messages
15
This one always gets me in a bind & I can't seem to find the answer anywhere... I would like to open a report where the field in the record source is a variable. The following works fine where the field is boolean:

DoCmd.OpenReport "rptReport", acViewPreview, , "[StringFieldName] = -1"

I would like the [StringFieldName] part of the where condition to be selected from a combobox on the same form. For example, Me.cboComboBox.Column(1). I never get the syntax right to get this to work, so would greatly appreciate any help! (I've tried many combinations but I am obviously misunderstanding the correct syntax).
 
Untested, but try

DoCmd.OpenReport "rptReport", acViewPreview, , Me.cboComboBox.Column(1) & " = -1"
 

Users who are viewing this thread

Back
Top Bottom