By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
444,124 Members | 1,945 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 444,124 IT Pros & Developers. It's quick & easy.

Problem

P: n/a
I am trying to write write a procedure for a button which will open a
report using the value of a field in the open form as the Where
parameter for DoCmd.Openreport. The value of the field is assigned to
a variable defined as an Integer, and the field to which I am assigning
the variable is an Autonumber field. But when I press the button I get
a message box prompting me for the value of the variable. What am I
doing wrong??? Code included below:

Private Sub Command45_Click()
Dim OrderNum As Integer
OrderNum = Forms!frmClientData!frmOrderSubform!OrderNo.Value

'Debug.Print OrderNum
DoCmd.OpenReport "rptReceipt", acViewPreview, ,
"[OrderNo]=OrderNum"

On Error GoTo Err_Command45_Click

Exit_Command45_Click:
Exit Sub

Err_Command45_Click:
MsgBox Err.Description
Resume Exit_Command45_Click

End Sub

May 23 '06 #1
Share this Question
Share on Google+
1 Reply


P: n/a
<ch***************@charter.net> wrote in message
news:11**********************@i39g2000cwa.googlegr oups.com...
I am trying to write write a procedure for a button which will open a
report using the value of a field in the open form as the Where
parameter for DoCmd.Openreport. The value of the field is assigned to
a variable defined as an Integer, and the field to which I am assigning
the variable is an Autonumber field. But when I press the button I get
a message box prompting me for the value of the variable. What am I
doing wrong??? Code included below:

Private Sub Command45_Click()
Dim OrderNum As Integer
OrderNum = Forms!frmClientData!frmOrderSubform!OrderNo.Value

'Debug.Print OrderNum
DoCmd.OpenReport "rptReceipt", acViewPreview, ,
"[OrderNo]=OrderNum"

On Error GoTo Err_Command45_Click

Exit_Command45_Click:
Exit Sub

Err_Command45_Click:
MsgBox Err.Description
Resume Exit_Command45_Click

End Sub


Try changing "[OrderNo]=OrderNum" to "[OrderNo] = " & OrderNum

Regards,
Keith.
www.keithwilby.com
May 23 '06 #2

This discussion thread is closed

Replies have been disabled for this discussion.