A Microsoft Office (Excel, Word) forum. OfficeFrustration

If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

Go Back   Home » OfficeFrustration forum » Microsoft Access » Using Forms
Site Map Home Register Authors List Search Today's Posts Mark Forums Read  

Print From Form



 
 
Thread Tools Display Modes
  #1  
Old June 4th, 2004, 08:21 PM
Bill
external usenet poster
 
Posts: n/a
Default Print From Form

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.
  #2  
Old June 5th, 2004, 01:59 AM
fredg
external usenet poster
 
Posts: n/a
Default Print From Form

On Fri, 4 Jun 2004 12:21:06 -0700, Bill wrote:

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.
--
Fred Please only reply to this newsgroup. I do not reply to personal
email.
  #3  
Old June 7th, 2004, 03:26 PM
Bill
external usenet poster
 
Posts: n/a
Default Print From Form

Thanks for straightening me out!
 




Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Forum Jump


All times are GMT +1. The time now is 10:55 AM.


Powered by vBulletin® Version 3.6.4
Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 OfficeFrustration.
The comments are property of their posters.