Print From Form

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

I have a command button on a form to print a report. I want to pass a two items from the form to the report query but I can't seem to get the code right. This is what I have

Private Sub cmdPrM1_Click(
On Error GoTo Err_cmdPrM1_Clic

Dim stDocName As Strin

stDocName = "VendMatl
DoCmd.OpenReport stDocName, acPreview, [ven_qte]![FGREF] = """ & Me.FGREF & """ And [ven_qte]![Name] = """ & Me.cbomsup1 & ""

Exit_cmdPrM1_Click
Exit Su

Err_cmdPrM1_Click
MsgBox Err.Descriptio
Resume Exit_cmdPrM1_Clic

End Su

What am I missing? Thanks in advance.
 
I have a command button on a form to print a report. I want to pass
a two items from the form to the report query but I can't seem to
get the code right. This is what I have:

Private Sub cmdPrM1_Click() On Error GoTo Err_cmdPrM1_Click

Dim stDocName As String

stDocName = "VendMatl"
DoCmd.OpenReport stDocName, acPreview,
[ven_qte]![FGREF] = """ & Me.FGREF & """ And [ven_qte]![Name] = """
& Me.cbomsup1 & """

Exit_cmdPrM1_Click: Exit Sub

Err_cmdPrM1_Click: MsgBox Err.Description Resume Exit_cmdPrM1_Click


End Sub

What am I missing? Thanks in advance.

You're missing at least one comma.
You placed your Where clause in the Filter argument position.

DoCmd.OpenReport stDocName, acPreview, ,[ven_qte]![FGREF] = etc.

You are also using a field named [Name].
Name is a reserved word in Access/VBA and should not be used as a
field name. I would suggest ClientName, or txtName, etc.
Is the datatype of the bound field of your combo box text (as written)
or is the bound field a Number datatype? In which case you also have
the syntax incorrect.

Try it now.
If you still have a problem, post back with an
explanation of the Field and control datatypes involved in the where
clause.
 
Back
Top