Opening Forms from a string

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.
 
F

fredg

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.
 

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

Top