lost in code argument

S

spence

I am trying to create a command button on a form that
prints records based on the field [DSIPA] in the form. I
am a complete newbie with code, but I have the following
in both Sub billreport_Click() and printbillreport_Click()
procedures:

Dim stDocName As String

stDocName = "BillingReport"
DoCmd.OpenReport stDocName, acNormal

Dim stWhere As String

stWhere = "[DSIPA] = " & txtDSIPA
DoCmd.OpenReport stDoc, acNormal, _
WhereCondition:=stWhere

When I try test it out I get an error that says "The
action or method requires a Report Name argument."

I'm out of my depth here by far. Can some kind soul help
me out here?

Thanks,
spence
 
D

Douglas J. Steele

You declared a variable stDocName, and assigned it a value of BillingReport.
However, your second OpenReport statement is trying to use stDoc as the
report name, and you haven't assigned it a value anywhere.
 
S

spence

Thanks, Doug. I think this is what comes of me trying to
cut and paste code that I have little understanding of. I
inherited this project along with a tight deadline with it.

Now that I've corrected my OpenReport statement, I have a
new error, which is:

Extra ) in query expression '([DSIPA]= ).'

I have no query expressions using [DSIPA] in parenthesis
anywhere in my project so I presume there's an error in my
code. Let me repaste what I now have:

Private Sub Command0_Click()
On Error GoTo Err_Command0_Click

Dim stDocName As String

stDocName = "Consumer Information1"
DoCmd.OpenReport stDocName, acNormal

Dim stWhere As String

stWhere = "[DSIPA] = " & txtDSIPA
DoCmd.OpenReport stDocName, acNormal, _
WhereCondition:=stWhere

Exit_Command0_Click:
Exit Sub

Err_Command0_Click:
MsgBox Err.Description
Resume Exit_Command0_Click

End Sub

I'm still stuck.
-----Original Message-----
You declared a variable stDocName, and assigned it a value of BillingReport.
However, your second OpenReport statement is trying to use stDoc as the
report name, and you haven't assigned it a value anywhere.

--
Doug Steele, Microsoft Access MVP

(No private e-mails, please)



I am trying to create a command button on a form that
prints records based on the field [DSIPA] in the form. I
am a complete newbie with code, but I have the following
in both Sub billreport_Click() and printbillreport_Click ()
procedures:

Dim stDocName As String

stDocName = "BillingReport"
DoCmd.OpenReport stDocName, acNormal

Dim stWhere As String

stWhere = "[DSIPA] = " & txtDSIPA
DoCmd.OpenReport stDoc, acNormal, _
WhereCondition:=stWhere

When I try test it out I get an error that says "The
action or method requires a Report Name argument."

I'm out of my depth here by far. Can some kind soul help
me out here?

Thanks,
spence


.
 
D

Douglas J. Steele

Does txtDSIPA have a value? You haven't declared it as a variable in your
procedure or assigned it a value, yet you're using it to create a WHERE
clause for your query.

--
Doug Steele, Microsoft Access MVP

(No private e-mails, please)



spence said:
Thanks, Doug. I think this is what comes of me trying to
cut and paste code that I have little understanding of. I
inherited this project along with a tight deadline with it.

Now that I've corrected my OpenReport statement, I have a
new error, which is:

Extra ) in query expression '([DSIPA]= ).'

I have no query expressions using [DSIPA] in parenthesis
anywhere in my project so I presume there's an error in my
code. Let me repaste what I now have:

Private Sub Command0_Click()
On Error GoTo Err_Command0_Click

Dim stDocName As String

stDocName = "Consumer Information1"
DoCmd.OpenReport stDocName, acNormal

Dim stWhere As String

stWhere = "[DSIPA] = " & txtDSIPA
DoCmd.OpenReport stDocName, acNormal, _
WhereCondition:=stWhere

Exit_Command0_Click:
Exit Sub

Err_Command0_Click:
MsgBox Err.Description
Resume Exit_Command0_Click

End Sub

I'm still stuck.
-----Original Message-----
You declared a variable stDocName, and assigned it a value of BillingReport.
However, your second OpenReport statement is trying to use stDoc as the
report name, and you haven't assigned it a value anywhere.

--
Doug Steele, Microsoft Access MVP

(No private e-mails, please)



I am trying to create a command button on a form that
prints records based on the field [DSIPA] in the form. I
am a complete newbie with code, but I have the following
in both Sub billreport_Click() and printbillreport_Click ()
procedures:

Dim stDocName As String

stDocName = "BillingReport"
DoCmd.OpenReport stDocName, acNormal

Dim stWhere As String

stWhere = "[DSIPA] = " & txtDSIPA
DoCmd.OpenReport stDoc, acNormal, _
WhereCondition:=stWhere

When I try test it out I get an error that says "The
action or method requires a Report Name argument."

I'm out of my depth here by far. Can some kind soul help
me out here?

Thanks,
spence


.
 

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