Opening Forms from a string

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

Guest

I've got a subroutine that identifites a couple of strings depending on info
that the user has entered.

This is the beginning of that subroutine:
Dim strDataSource As String
Dim strReportName As String
Dim strLabelName As String
Select Case Me.txtReportType
Case "All Adults"
strDataSource = "qryContactsAll"
strReportName = "rptContacts"
strLabelName = "lblContacts"
(There are 13 or 14 cases in all).

Then I've got another subroutine that is supposed to run that sub & then
open a report based upon the strReportName. I've got the following command
line in there:

DoCmd.OpenReport strReportName

I get a Run-time Error '2497": The action or method requires a Report Name
argument.

Any suggestions on how to get this working?

Thanks.
 
I've got a subroutine that identifites a couple of strings depending on info
that the user has entered.

This is the beginning of that subroutine:
Dim strDataSource As String
Dim strReportName As String
Dim strLabelName As String
Select Case Me.txtReportType
Case "All Adults"
strDataSource = "qryContactsAll"
strReportName = "rptContacts"
strLabelName = "lblContacts"
(There are 13 or 14 cases in all).

Then I've got another subroutine that is supposed to run that sub & then
open a report based upon the strReportName. I've got the following command
line in there:

DoCmd.OpenReport strReportName

I get a Run-time Error '2497": The action or method requires a Report Name
argument.

Any suggestions on how to get this working?

Thanks.

Place a
Debug.print "Report type " & txtReportType & " Report Name " &
strReportName
right before the OpenReport and see what the last value is before the
OpenReport is run. If it is blank, move the debug.print up one line.
Repeat as often as is necessary to find where the code is going wrong.
You could also use a msgbox instead of debug.print if you like.
 
Back
Top