cmdbutton

  • Thread starter Thread starter nydia
  • Start date Start date
N

nydia

i have a cmd button on a form and what i want this button
to do is when clicked, i want it to open the report on the
current client. i have the following code, but when the
button is clicked i get the following message "the action
or method requires a report name argument" how can i get
it to open this specific report for the current client??

Private Sub cmdOpenRpt4File_Click()
On Error GoTo Err_cmdOpenRpt4File_Click

Dim stDocName As String
Dim stlinkcriteria As String

stDocName = "rptClientInfo4File"

stlinkcriteria = "[ClientID]=" & Me![ClientID]
DoCmd.OpenReport stdoc, acPreview, stlinkcriteria

Exit_cmdOpenRpt4File_Click:
Exit Sub

Err_cmdOpenRpt4File_Click:
MsgBox Err.Description
Resume Exit_cmdOpenRpt4File_Click

End Sub
 
Your code has STDOCNAME as the variable for the name, but in your open
command you entered STDOC. It should say

DoCmd.OpenReport stdocNAME, acPreview, stlinkcriteria

Rick
 
i have a cmd button on a form and what i want this button
to do is when clicked, i want it to open the report on the
current client. i have the following code, but when the
button is clicked i get the following message "the action
or method requires a report name argument" how can i get
it to open this specific report for the current client??

Private Sub cmdOpenRpt4File_Click()
On Error GoTo Err_cmdOpenRpt4File_Click

Dim stDocName As String
Dim stlinkcriteria As String

stDocName = "rptClientInfo4File"

stlinkcriteria = "[ClientID]=" & Me![ClientID]
DoCmd.OpenReport stdoc, acPreview, stlinkcriteria

Exit_cmdOpenRpt4File_Click:
Exit Sub

Err_cmdOpenRpt4File_Click:
MsgBox Err.Description
Resume Exit_cmdOpenRpt4File_Click

End Sub

You have 2 problems.
1) You have stDocName containing the name of the report, but your
OpenReport code calls for stdoc. stdoc has no value and this is
causing your error message.

Had you used Option Explicit in the Code Declarations section, Access
would have not compiled the code and would have highlighted the error.

2) You have placed the stLinkCriteria in the wrong argument position.
It belongs in the Where position, not in the Filter postion.

Try:
DoCmd.OpenReport stDocName, acPreview, , stlinkcriteria
 
i tried putting the stlinkcriteria in the where like you
stated, but now when i click on the button, i am getting a
pop-up asking for clientID, if i click ok and dont put any
id, it will bring up a blank report. how do i fix this
-----Original Message-----
i have a cmd button on a form and what i want this button
to do is when clicked, i want it to open the report on the
current client. i have the following code, but when the
button is clicked i get the following message "the action
or method requires a report name argument" how can i get
it to open this specific report for the current client??

Private Sub cmdOpenRpt4File_Click()
On Error GoTo Err_cmdOpenRpt4File_Click

Dim stDocName As String
Dim stlinkcriteria As String

stDocName = "rptClientInfo4File"

stlinkcriteria = "[ClientID]=" & Me![ClientID]
DoCmd.OpenReport stdoc, acPreview, stlinkcriteria

Exit_cmdOpenRpt4File_Click:
Exit Sub

Err_cmdOpenRpt4File_Click:
MsgBox Err.Description
Resume Exit_cmdOpenRpt4File_Click

End Sub

You have 2 problems.
1) You have stDocName containing the name of the report, but your
OpenReport code calls for stdoc. stdoc has no value and this is
causing your error message.

Had you used Option Explicit in the Code Declarations section, Access
would have not compiled the code and would have highlighted the error.

2) You have placed the stLinkCriteria in the wrong argument position.
It belongs in the Where position, not in the Filter postion.

Try:
DoCmd.OpenReport stDocName, acPreview, , stlinkcriteria

--
Fred
Please only reply to this newsgroup.
I do not reply to personal email.
.
 
disregard my post reply, i figured it out, i didn't have
the clientid as a field in the report, once i added it, it
works. thanks so much for your help. :)
-----Original Message-----
i have a cmd button on a form and what i want this button
to do is when clicked, i want it to open the report on the
current client. i have the following code, but when the
button is clicked i get the following message "the action
or method requires a report name argument" how can i get
it to open this specific report for the current client??

Private Sub cmdOpenRpt4File_Click()
On Error GoTo Err_cmdOpenRpt4File_Click

Dim stDocName As String
Dim stlinkcriteria As String

stDocName = "rptClientInfo4File"

stlinkcriteria = "[ClientID]=" & Me![ClientID]
DoCmd.OpenReport stdoc, acPreview, stlinkcriteria

Exit_cmdOpenRpt4File_Click:
Exit Sub

Err_cmdOpenRpt4File_Click:
MsgBox Err.Description
Resume Exit_cmdOpenRpt4File_Click

End Sub

You have 2 problems.
1) You have stDocName containing the name of the report, but your
OpenReport code calls for stdoc. stdoc has no value and this is
causing your error message.

Had you used Option Explicit in the Code Declarations section, Access
would have not compiled the code and would have highlighted the error.

2) You have placed the stLinkCriteria in the wrong argument position.
It belongs in the Where position, not in the Filter postion.

Try:
DoCmd.OpenReport stDocName, acPreview, , stlinkcriteria

--
Fred
Please only reply to this newsgroup.
I do not reply to personal email.
.
 
thanks for your help
-----Original Message-----
Your code has STDOCNAME as the variable for the name, but in your open
command you entered STDOC. It should say

DoCmd.OpenReport stdocNAME, acPreview, stlinkcriteria

Rick



i have a cmd button on a form and what i want this button
to do is when clicked, i want it to open the report on the
current client. i have the following code, but when the
button is clicked i get the following message "the action
or method requires a report name argument" how can i get
it to open this specific report for the current client??

Private Sub cmdOpenRpt4File_Click()
On Error GoTo Err_cmdOpenRpt4File_Click

Dim stDocName As String
Dim stlinkcriteria As String

stDocName = "rptClientInfo4File"

stlinkcriteria = "[ClientID]=" & Me![ClientID]
DoCmd.OpenReport stdoc, acPreview, stlinkcriteria

Exit_cmdOpenRpt4File_Click:
Exit Sub

Err_cmdOpenRpt4File_Click:
MsgBox Err.Description
Resume Exit_cmdOpenRpt4File_Click

End Sub


.
 
Back
Top