print command

G

Guest

Hi, I've read all previous related questions but am a conplete novice at this
so need simple language!

I have DB (access 2002) called 'clients' which is displayed in form mode.
When a new client information is added i wish to have a command button that
will merge certain fields to exsisting docs ( about 30 in all) and then print
all the docs automatically for that record?

Do I have to merge all the docs first with field info etc? They are all in
one folder C:\Documents and Settings\numbered docs. Can it be done via
expression builder or does it have to be a macro? of which I know nothing!

Please be patient and keep it simple please! We all have to start somewhere:)
 
A

Arvin Meyer [MVP]

Jo said:
Hi, I've read all previous related questions but am a conplete novice at
this
so need simple language!

I have DB (access 2002) called 'clients' which is displayed in form mode.
When a new client information is added i wish to have a command button
that
will merge certain fields to exsisting docs ( about 30 in all) and then
print
all the docs automatically for that record?

Do I have to merge all the docs first with field info etc? They are all in
one folder C:\Documents and Settings\numbered docs. Can it be done via
expression builder or does it have to be a macro? of which I know nothing!

Please be patient and keep it simple please! We all have to start
somewhere:)
 
A

Arvin Meyer [MVP]

This is the 2nd time today that I sent too soon, must be a gremlin in the
computer <g>

You need to tell us what kind of docs that you're talking about. You can
print a Word.doc simply by setting a reference to Word in Tools >>
References in any code window, then:

Public Function PrintDoc(ByVal strDoc As String)
Dim objWord As Word.Application

With objWord
.Open strDoc
.PrintOut
.Documents(strDoc).Close
.Quit
End With

Set objWord = Nothing
End Function
 
G

Guest

Thanks for the advice. The docs in question are straight forword Word docs.
Presently when a new client arrives, we print off all these Word documents
and fill in the client information by hand. I want to be able to enter all
their informatioon in a form record and then have all the documents print
off in one go with all the client information already in them taken from the
record fields information just entered.

I take it I just cut and paste the coding you gave into a macro and that
will work?

Thanks again for your patience and time, it's much appreciated.
 
K

keri

If I am understanding correctly I would create a button at the bottom
of your form that says "Print this Form" or something like this.
(Create a button on the form in design view by clicking on the
"CommandButton" button on the toolbar and drawing your button where you
want it on the page. If you do not have this button available right
click on your toolbar at the top of the page - in design view - and
select toolbox. This button should now be available.)
When you have drawn the button you should get a box called command
button wizard. Select Form Operations and Print Current Form - then
click Next. Then select what you want on your button eg Text "Print
This Form" or a picture of a printer. Then click Next. You are now
asked to name the command - change the name from Command1 (or whatever
it is automatically called) to something like CmdPrintClientForm - or
whatever - this will make it easy for you to identify later. Then
click Finish & Voila. You may now want to resize or move your button on
the form.
When you view your form in Form View your print button will be there
ready to use.

You could also add some little things to the button to make it a bit
more user friendly. Go back into design view and right click on the
button and select properties. Under the event tab click the little
button to the right of the On Click Line (where it says event
procedure). This will open up the VBA code editor window. The code you
see will look something like this;

Private Sub CmdPrintClientForm_Click()
On Error GoTo Err_CmdPrintClientForm_Click


DoCmd.PrintOut

Exit_CmdPrintClientForm_Click:
Exit Sub

Err_CmdPrintClientForm_Click:
msgbox Err.Description
Resume Exit_CmdPrintClientForm_Click

End Sub

If you add this line of code;
msgbox("The form is now printing")
when the button is pressed the user will get a message telling them
that the form is printing.

Your code should now look like this;

Private Sub CmdPrintClientForm_Click()
On Error GoTo Err_CmdPrintClientForm_Click


DoCmd.PrintOut
msgbox("The form is now printing")

Exit_CmdPrintClientForm_Click:
Exit Sub

Err_CmdPrintClientForm_Click:
msgbox Err.Description
Resume Exit_CmdPrintClientForm_Click

End Sub

Click save on the VBA editor and close it.
Hope this helps and is clear to understand.
 

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