case statement question please help

D

David M. Fizer

Can someone please tell me what this means. I have used it in a old
database but since then have change the name of my tables and forms and am
not sure what to change in this case statement to get it to work.

Private Sub Preview_Click()
0 Dim varSelectedUPC As Variant
Dim StrUPC As String

For Each varSelectedUPC In UPC.ItemsSelected
StrUPC = UPC.ItemData(varSelectedUPC)
Select Case StrUPC
Case "39000 48164"
DoCmd.OpenReport "rptNestle T-Wing", acViewPreview, , "UPC = '"
& StrUPC & "'"
End Select

Next varSelectedUPC

End Sub


Thank you in advance,
David
 
D

Douglas J Steele

Pretty difficult for us to advise you without any idea of what you're trying
to do... <g>

The code you're posting assumes that there's a multiselect listbox named UPC
on your form. It loops through all of the selected entries in the listbox,
and if the "39000 48164" has been selected, it opens report "rptNestle
T-Wing", passing it that UPC code.

As long as you still have the multiselect listbox with that name (and it
works...), you shouldn't need to make any changes.
 
D

David M. Fizer

Thank you Doug for your reply you are absolutltely right that is the basis
of that statement. The problem I am having is when I select the UPC from
the list and click the preview button I get a parameter box asking to
enter a UPC with a text box, after I click Ok I get another parameter box
that just says UPC with a text box. I checked the name of the list box and
its still named UPC and the row source is a field in a table. Is there
anything else that I'm missing and could do. Thanks againg Doug.



David
 
D

Douglas J. Steele

What you're describing implies that the field name has been changed from UPC
to something else in the table or query that makes up the RecordSource for
the report.
 
D

David M. Fizer

That is true I renamed the field to strProductID my problem is that when
this statement worked my table, field, form, and list box were all named
UPC and now I am not sure what to change in the statement.

TIA
David
 
D

Douglas J. Steele

If the field in the query that's the recordsource for your report is named
strProductID, that's what you need in that 4th parameter:

DoCmd.OpenReport "rptNestle T-Wing", acViewPreview, , "strProductID = '" &
StrUPC & "'"

BTW, you're trimming too much from your messages. It's a real pain to have
to find your previous posts so that I can give you a complete answer!
 
D

David M. Fizer

Thank you Doug that worked Great. I'm sorry for cutting out my original
post from my reply. I now know not to thanks again.


David
 

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

Similar Threads

view multiple reports 2
event procedure 2
SQL statement 10
Case function 4
run-time error 3464 2
I get unexpected error 2
Case Statement Problem 3
Case statement Problem 25

Top