Do "In(1,3,5, 8)" in If/Then structure?

  • Thread starter Thread starter Fred Boer
  • Start date Start date
F

Fred Boer

Hello!

I have the following code:

If Me.cboMediaFormat = 3 Or Me.cboMediaFormat = 4 Or Me.cboMediaFormat = 7
Or Me.cboMediaFormat = 8 Then
msgbox "This is not the correct report for this type of media.
Please choose one of the talking book reports.", vbOKOnly + vbInformation,
"W. Ross Macdonald School Library "
Else
Call fncPrintBarcodeAndSpine
End If

I have to create another If/Then, which checks for 8 possible values of the
combobox. Is there a better way to do this? Am I missing something simple?
I.e. something like "If Me.cboMediaFormat In(1,2,5,6,9,10,11,12) Then..."

Thanks!
Fred Boer
 
Fred Boer wrote in message said:
Hello!

I have the following code:

If Me.cboMediaFormat = 3 Or Me.cboMediaFormat = 4 Or Me.cboMediaFormat = 7 Or
Me.cboMediaFormat = 8 Then
msgbox "This is not the correct report for this type of media.
Please choose one of the talking book reports.", vbOKOnly + vbInformation,
"W. Ross Macdonald School Library "
Else
Call fncPrintBarcodeAndSpine
End If

I have to create another If/Then, which checks for 8 possible values of the
combobox. Is there a better way to do this? Am I missing something simple?
I.e. something like "If Me.cboMediaFormat In(1,2,5,6,9,10,11,12) Then..."

Thanks!
Fred Boer

Try the Select Case - think it's something like this;

Select Case Me.cboMediaFormat
Case 3, 4, 7, 8
msgbox "blah"
Case 1,2,5,6,9 to 12
msgbox "blah2"
Case else
Call fncPrintBarcodeAndSpine
End Select
 
Dear Roy:

Thank you very much! That was exactly what I needed. I *did* know about the
Select Case structure, but I hadn't seen it used with a list of possible
values. That is a good thing to know about!

Cheers!
Fred Boer
 
Back
Top