Run Command canceled

G

Guest

I have some (I thought) simple code to save a record so that when an
associated form was opened for printing it would have the current info. I
tested it and it worked fine the first time. Now I'm getting a "RunCommand
action was canceled" message. I can't figure out what's changed:
Here's the code:

Private Sub cmdOpenChesapeake_Click()
On Error GoTo Err_cmdOpenChesapeake_Click

Dim stDocName As String
Dim stLinkCriteria As String

Me.Dirty = False
DoCmd.RunCommand acCmdSave
stDocName = "Lease Purchase Report CELP"

stLinkCriteria = "[LPR_No]=" & "'" & Me![LPR_No] & "'"
DoCmd.OpenForm stDocName, , , stLinkCriteria


Exit_cmdOpenChesapeake_Click:
Exit Sub

Thanks!
 
F

fredg

I have some (I thought) simple code to save a record so that when an
associated form was opened for printing it would have the current info. I
tested it and it worked fine the first time. Now I'm getting a "RunCommand
action was canceled" message. I can't figure out what's changed:
Here's the code:

Private Sub cmdOpenChesapeake_Click()
On Error GoTo Err_cmdOpenChesapeake_Click

Dim stDocName As String
Dim stLinkCriteria As String

Me.Dirty = False
DoCmd.RunCommand acCmdSave
stDocName = "Lease Purchase Report CELP"

stLinkCriteria = "[LPR_No]=" & "'" & Me![LPR_No] & "'"
DoCmd.OpenForm stDocName, , , stLinkCriteria

Exit_cmdOpenChesapeake_Click:
Exit Sub

Thanks!


Private Sub cmdOpenChesapeake_Click()
On Error GoTo Err_cmdOpenChesapeake_Click

Dim stDocName As String
Dim stLinkCriteria As String

DoCmd.RunCommand acCmdSaveRecord
stDocName = "Lease Purchase Report CELP"

stLinkCriteria = "[LPR_No]= '" & Me![LPR_No] & "'"
DoCmd.OpenForm stDocName, , , stLinkCriteria

Exit_cmdOpenChesapeake_Click:
Exit Sub
End Sub

The command is acCmdSaveRecord, not acCmdSave.

The above stLinkCriteria assumes [LPR_No] is Text datatype.
Just for clarity, the quotes are:
"[LPR_No]= ' " & Me![LPR_No] & " ' "

If, however, [LPR_No] is a Number datatype, use:
stLinkCriteria = "[LPR_No]= " & Me![LPR_No]
 
G

Guest

Works great fredg! Thanks. So "Save" is just for design changes etc? (Yeah,
LPR "number" was a text type.)

fredg said:
I have some (I thought) simple code to save a record so that when an
associated form was opened for printing it would have the current info. I
tested it and it worked fine the first time. Now I'm getting a "RunCommand
action was canceled" message. I can't figure out what's changed:
Here's the code:

Private Sub cmdOpenChesapeake_Click()
On Error GoTo Err_cmdOpenChesapeake_Click

Dim stDocName As String
Dim stLinkCriteria As String

Me.Dirty = False
DoCmd.RunCommand acCmdSave
stDocName = "Lease Purchase Report CELP"

stLinkCriteria = "[LPR_No]=" & "'" & Me![LPR_No] & "'"
DoCmd.OpenForm stDocName, , , stLinkCriteria

Exit_cmdOpenChesapeake_Click:
Exit Sub

Thanks!


Private Sub cmdOpenChesapeake_Click()
On Error GoTo Err_cmdOpenChesapeake_Click

Dim stDocName As String
Dim stLinkCriteria As String

DoCmd.RunCommand acCmdSaveRecord
stDocName = "Lease Purchase Report CELP"

stLinkCriteria = "[LPR_No]= '" & Me![LPR_No] & "'"
DoCmd.OpenForm stDocName, , , stLinkCriteria

Exit_cmdOpenChesapeake_Click:
Exit Sub
End Sub

The command is acCmdSaveRecord, not acCmdSave.

The above stLinkCriteria assumes [LPR_No] is Text datatype.
Just for clarity, the quotes are:
"[LPR_No]= ' " & Me![LPR_No] & " ' "

If, however, [LPR_No] is a Number datatype, use:
stLinkCriteria = "[LPR_No]= " & Me![LPR_No]
 

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