wherecondition syntax

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!
 
D

Duane Hookom

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
 
M

MoonBlosm

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!
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top