wherecondition syntax

  • Thread starter Thread starter MoonBlosm
  • Start date Start date
M

MoonBlosm

I have a combo box on a form. When a user selects item #16042, I want the
report to open up with item #16042, 16043, 16044 since they are all really
part of that item but separate entities in the table. However, I am having
trouble with the syntax of how to put it in the where statement.

If Me.Combo1 = "16042" Then
stFilterName = "16042 or 16043 or 16044"
else
stfiltername = me.combo1
end if
stWhere = stWhere & "[item] = '" & stFilterName & "'"
DoCmd.OpenReport stDocName, acPreview, , stWhere

Right now, nothing happens
I am sure it is in the syntax I am using.

Any help would be apprciated!
 
Try:
If Me.Combo1 = "16042" Then
'it looks like Item is text
stFilterName = " IN ('16042','16043','16044')"
else
stfiltername = " = '" & me.combo1 & "'"
end if
stWhere = stWhere & "[item] " & stFilterName
DoCmd.OpenReport stDocName, acPreview, , stWhere
 
Awesome. That worked like a charm. Thank goodness for this community spot
where are the knowledgable people hang out!

Thank you so very much for being willing to share your knowledge and
answering so quickly.

Duane Hookom said:
Try:
If Me.Combo1 = "16042" Then
'it looks like Item is text
stFilterName = " IN ('16042','16043','16044')"
else
stfiltername = " = '" & me.combo1 & "'"
end if
stWhere = stWhere & "[item] " & stFilterName
DoCmd.OpenReport stDocName, acPreview, , stWhere

--
Duane Hookom
Microsoft Access MVP


MoonBlosm said:
I have a combo box on a form. When a user selects item #16042, I want the
report to open up with item #16042, 16043, 16044 since they are all really
part of that item but separate entities in the table. However, I am having
trouble with the syntax of how to put it in the where statement.

If Me.Combo1 = "16042" Then
stFilterName = "16042 or 16043 or 16044"
else
stfiltername = me.combo1
end if
stWhere = stWhere & "[item] = '" & stFilterName & "'"
DoCmd.OpenReport stDocName, acPreview, , stWhere

Right now, nothing happens
I am sure it is in the syntax I am using.

Any help would be apprciated!
 
Back
Top