Case Statement

D

David M. Fizer

Hello Everyone,


I have an event procedure which has a case statement that when a user
selects a record from a list box that a related report opens. I wanted to
make this easier to manage when new records are entered and need to choose
which report to use. Is there a way to add a field to my existing table
where after the end user enters in all the data for a product could enter
which report opens up when that record is selected.Below is the partial
case statement that I am using and can get very long and confusing when a
new record is added.

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 "Nestle T-Wing", acViewPreview, , "UPC = '" &
StrUPC & "'"
Case "06010 11292" To "06010 11588", "76808 52094", "76808 52138",
"95059 00046" To "95059 00051"
DoCmd.OpenReport "Barilla", acViewPreview, , "UPC = '" & StrUPC
& "'"
Case "MAR 001"
DoCmd.OpenReport "Mario", acViewPreview, , "UPC = '" & StrUPC &
"'"
Case Else
DoCmd.OpenReport "Others", acViewPreview, , "UPC = '" & StrUPC &
"'"

End Select

Next varSelectedUPC

End Sub



TIA,
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 3
event procedure 2
SQL statement 10
case statement question please help 6
Case function 4
run-time error 3464 2
Case statement Problem 25
Help with If or Case 6

Top