acViewNormal - Print Current Form

G

Guest

Hi there;

I am trying to print a current form as a report. Here is the code I am using:
Private Sub Command33_Click()
DoCmd.OpenReport "InvoicePayment", acViewNormal, , _
"[InvoiceNumber]=Forms!InvoicePayment"
End Sub

When I click my command button, the form prints out however it does not
print the form's actual contents. i.e. what I have entered into the form.
It just prints the outline format of the report. Any help would be
appreciated!"
 
J

jahoobob via AccessMonster.com

When addressing a control on a form, as you are trying to do in your criteria,
you have to give the form name and the control name
i.e. Forms!formname.controlname
Hi there;

I am trying to print a current form as a report. Here is the code I am using:
Private Sub Command33_Click()
DoCmd.OpenReport "InvoicePayment", acViewNormal, , _
"[InvoiceNumber]=Forms!InvoicePayment"
End Sub

When I click my command button, the form prints out however it does not
print the form's actual contents. i.e. what I have entered into the form.
It just prints the outline format of the report. Any help would be
appreciated!"
 
M

missinglinq via AccessMonster.com

Are you entering data in a new record and then trying to print out that
record? If so, you need to save the record first, then print it. If this is
the case, in the line immediately preceding the line to open the report use
either

docmd.RunCommand acCmdSaveRecord

or

If Me.Dirty Then Me.Dirty = False

to save the new record.

Linq

--
There's ALWAYS more than one way to skin a cat!

Answers/posts based on Access 2000

Message posted via AccessMonster.com
 
G

Guest

Where does that appear in the script?

jahoobob via AccessMonster.com said:
When addressing a control on a form, as you are trying to do in your criteria,
you have to give the form name and the control name
i.e. Forms!formname.controlname
Hi there;

I am trying to print a current form as a report. Here is the code I am using:
Private Sub Command33_Click()
DoCmd.OpenReport "InvoicePayment", acViewNormal, , _
"[InvoiceNumber]=Forms!InvoicePayment"
End Sub

When I click my command button, the form prints out however it does not
print the form's actual contents. i.e. what I have entered into the form.
It just prints the outline format of the report. Any help would be
appreciated!"
 
G

Guest

linq;

That is exactly what I am trying to do. When I enter a new record I want to
save it. I tried adding that line, however it still prints without any of
the inputted data.

This is the revised code I used.

Private Sub Command33_Click()
DoCmd.RunCommand acCmdSaveRecord
DoCmd.OpenReport "InvoicePayment", acViewNormal, , _
"[InvoiceNumber]=Forms!InvoicePayment"
End Sub
 
D

Douglas J. Steele

DoCmd.OpenReport "InvoicePayment", acViewNormal, , _
"[InvoiceNumber]=Forms!InvoicePayment"

That should actually be

DoCmd.OpenReport "InvoicePayment", acViewNormal, , _
"[InvoiceNumber]=" & Forms!NameOfForm!INameOfControl

if InvoiceNumber is numeric, or

DoCmd.OpenReport "InvoicePayment", acViewNormal, , _
"[InvoiceNumber]='" & Forms!NameOfForm!NameOfControl & "'"

if it's text.



--
Doug Steele, Microsoft Access MVP

(no private e-mails, please)


DARYL said:
Where does that appear in the script?

jahoobob via AccessMonster.com said:
When addressing a control on a form, as you are trying to do in your
criteria,
you have to give the form name and the control name
i.e. Forms!formname.controlname
Hi there;

I am trying to print a current form as a report. Here is the code I am
using:
Private Sub Command33_Click()
DoCmd.OpenReport "InvoicePayment", acViewNormal, , _
"[InvoiceNumber]=Forms!InvoicePayment"
End Sub

When I click my command button, the form prints out however it does not
print the form's actual contents. i.e. what I have entered into the
form.
It just prints the outline format of the report. Any help would be
appreciated!"
 
G

Guest

Doug;

Thanks a lot for that. What command do you refer to. The button command
number?

Douglas J. Steele said:
DoCmd.OpenReport "InvoicePayment", acViewNormal, , _
"[InvoiceNumber]=Forms!InvoicePayment"

That should actually be

DoCmd.OpenReport "InvoicePayment", acViewNormal, , _
"[InvoiceNumber]=" & Forms!NameOfForm!INameOfControl

if InvoiceNumber is numeric, or

DoCmd.OpenReport "InvoicePayment", acViewNormal, , _
"[InvoiceNumber]='" & Forms!NameOfForm!NameOfControl & "'"

if it's text.



--
Doug Steele, Microsoft Access MVP

(no private e-mails, please)


DARYL said:
Where does that appear in the script?

jahoobob via AccessMonster.com said:
When addressing a control on a form, as you are trying to do in your
criteria,
you have to give the form name and the control name
i.e. Forms!formname.controlname

DARYL wrote:
Hi there;

I am trying to print a current form as a report. Here is the code I am
using:
Private Sub Command33_Click()
DoCmd.OpenReport "InvoicePayment", acViewNormal, , _
"[InvoiceNumber]=Forms!InvoicePayment"
End Sub

When I click my command button, the form prints out however it does not
print the form's actual contents. i.e. what I have entered into the
form.
It just prints the outline format of the report. Any help would be
appreciated!"
 
G

Guest

Sorry I mean Control.. What control do I select.. All the controls on the form?

DARYL said:
Doug;

Thanks a lot for that. What command do you refer to. The button command
number?

Douglas J. Steele said:
DoCmd.OpenReport "InvoicePayment", acViewNormal, , _
"[InvoiceNumber]=Forms!InvoicePayment"

That should actually be

DoCmd.OpenReport "InvoicePayment", acViewNormal, , _
"[InvoiceNumber]=" & Forms!NameOfForm!INameOfControl

if InvoiceNumber is numeric, or

DoCmd.OpenReport "InvoicePayment", acViewNormal, , _
"[InvoiceNumber]='" & Forms!NameOfForm!NameOfControl & "'"

if it's text.



--
Doug Steele, Microsoft Access MVP

(no private e-mails, please)


DARYL said:
Where does that appear in the script?

:

When addressing a control on a form, as you are trying to do in your
criteria,
you have to give the form name and the control name
i.e. Forms!formname.controlname

DARYL wrote:
Hi there;

I am trying to print a current form as a report. Here is the code I am
using:
Private Sub Command33_Click()
DoCmd.OpenReport "InvoicePayment", acViewNormal, , _
"[InvoiceNumber]=Forms!InvoicePayment"
End Sub

When I click my command button, the form prints out however it does not
print the form's actual contents. i.e. what I have entered into the
form.
It just prints the outline format of the report. Any help would be
appreciated!"
 
D

Douglas J. Steele

I'm not sure I understand your question.

You're trying to limit your report to a specific item. You'd refer to
whatever control(s) are necessary in order to limit the report to a single
item.

Reading back through your question, though, does your report open normally
when you don't try to limit it? In other words, do you get a report with
many entries on it normally?

--
Doug Steele, Microsoft Access MVP

(no e-mails, please!)


DARYL said:
Sorry I mean Control.. What control do I select.. All the controls on the
form?

DARYL said:
Doug;

Thanks a lot for that. What command do you refer to. The button command
number?

Douglas J. Steele said:
DoCmd.OpenReport "InvoicePayment", acViewNormal, , _
"[InvoiceNumber]=Forms!InvoicePayment"

That should actually be

DoCmd.OpenReport "InvoicePayment", acViewNormal, , _
"[InvoiceNumber]=" & Forms!NameOfForm!INameOfControl

if InvoiceNumber is numeric, or

DoCmd.OpenReport "InvoicePayment", acViewNormal, , _
"[InvoiceNumber]='" & Forms!NameOfForm!NameOfControl &
"'"

if it's text.



--
Doug Steele, Microsoft Access MVP

(no private e-mails, please)


Where does that appear in the script?

:

When addressing a control on a form, as you are trying to do in your
criteria,
you have to give the form name and the control name
i.e. Forms!formname.controlname

DARYL wrote:
Hi there;

I am trying to print a current form as a report. Here is the code
I am
using:
Private Sub Command33_Click()
DoCmd.OpenReport "InvoicePayment", acViewNormal, , _
"[InvoiceNumber]=Forms!InvoicePayment"
End Sub

When I click my command button, the form prints out however it does
not
print the form's actual contents. i.e. what I have entered into
the
form.
It just prints the outline format of the report. Any help would be
appreciated!"
 

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