combo box issue - again

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

Okay, here is the code that I have, which is behind the command button to run report. The combo box lists the selections. When I click on the selection in the dropdown and then click command button to run the report, nothing happens. What am I doing wrong? I've tried taking the Case Else out, but still nothing.

Dim stDocName As Strin

Select Case [cboSelectReport
Case "MA1
stDocName = "MA1 All

Case "MA2
stDocName = "MA2 All

Case "MA3
stDocName = "MA3 All

Case "MG1
stDocName = "MG1 All

Case "MG3
stDocName = "MG3 All
Case Els

DoCmd.OpenReport stDocName, acViewPrevie

End Selec
 
The DoCmd statement should come after the End Select.

Hope That Helps
Gerald Stanley MCSD
-----Original Message-----
Okay, here is the code that I have, which is behind the
command button to run report. The combo box lists the
selections. When I click on the selection in the dropdown
and then click command button to run the report, nothing
happens. What am I doing wrong? I've tried taking the Case
Else out, but still nothing.
Dim stDocName As String

Select Case [cboSelectReport]
Case "MA1"
stDocName = "MA1 All"

Case "MA2"
stDocName = "MA2 All"

Case "MA3"
stDocName = "MA3 All"

Case "MG1"
stDocName = "MG1 All"

Case "MG3"
stDocName = "MG3 All"
Case Else

DoCmd.OpenReport stDocName, acViewPreview

End Select

.
 
Have you stepped through the code to prove that the correct
string is being passed through to the DoCmd statement. If
you are not used to stepping through code, put a message
box statement in the Case Else clause e.g.

Case Else
Msgbox "Value of cboSelectReport = " & cboSelectReport
, vbokonly

Hope That Helps
Gerald Stanley MCSD
 
grrrr! Boy, am I getting frustrated. I know it is probably something very simple, but still nothing happens. Do I have the brackets in the right place?. Are there supposed to be [] around the cboSelectReport because it is a combo box? I have tried both ways. What in the world could I be doing wrong?

----- Gerald Stanley wrote: ----

Have you stepped through the code to prove that the correc
string is being passed through to the DoCmd statement. I
you are not used to stepping through code, put a messag
box statement in the Case Else clause e.g

Case Els
Msgbox "Value of cboSelectReport = " & cboSelectRepor
, vbokonl

Hope That Help
Gerald Stanley MCS
 
Karen

Since the report names are two separate words, try
surrounding them with brackets inside the quotes

Don't stop grinning,
You'll Start winning
-----Original Message-----
Okay, here is the code that I have, which is behind the
command button to run report. The combo box lists the
selections. When I click on the selection in the dropdown
and then click command button to run the report, nothing
happens. What am I doing wrong? I've tried taking the Case
Else out, but still nothing.
Dim stDocName As String

Select Case [cboSelectReport]
Case "MA1"
stDocName = "MA1 All"

Case "MA2"
stDocName = "MA2 All"

Case "MA3"
stDocName = "MA3 All"

Case "MG1"
stDocName = "MG1 All"

Case "MG3"
stDocName = "MG3 All"
Case Else

DoCmd.OpenReport stDocName, acViewPreview

End Select

.
 
The [] should be immaterial. The msgbox statement in the
Case Else clause will trap the fact that stDocName is not
being set. Also, if the value of stDocName did not match
one of your report names, you should get an error message.
In the absence of either message, I am at a loss.

Gerald Stanley MCSD
-----Original Message-----
grrrr! Boy, am I getting frustrated. I know it is probably
something very simple, but still nothing happens. Do I have
the brackets in the right place?. Are there supposed to be
[] around the cboSelectReport because it is a combo box? I
have tried both ways. What in the world could I be doing
wrong?
 
Back
Top