Printing

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

Guest

Hi

I am new to access vba. Can you tell me if on a report that prompts for
information. ie: qty made, batch no and order ref. At the moment it works
fine this is to produce labels so the infor i input prints a label with that
information on. What i would like to do is for it to ask me how many copies
i want to print. Just like the print command you would normally use.

Many thanks
 
One solution would be to use an InputBox function to ask the user the number
of copies required then use the use the PrintOut method of the DoCmd object.

Check Access Help on DoCmd objects.

Daniel
 
Hi Daniel

Thanks for your help i will do that

many thanks again






- Show quoted text -




You kindley replied to my forum discussion.

I am still new to this and am struggling where to put the suggested
code. I wondered if you could look at this for me

Many thanks







Option Compare Database

Private Sub Belt_Differance_BeforeUpdate(Cancel As Integer)

End Sub

Private Sub FindRecord_Click()
On Error GoTo Err_FindRecord_Click


Screen.PreviousControl.SetFocus
DoCmd.DoMenuItem acFormBar, acEditMenu, 10, , acMenuVer70

Exit_FindRecord_Click:
Exit Sub

Err_FindRecord_Click:
MsgBox Err.Description
Resume Exit_FindRecord_Click

End Sub
Private Sub Print_Click()
On Error GoTo Err_Print_Click

Dim stDocName As String
Dim MyForm As Form

stDocName = "Input Form 2"
Set MyForm = Screen.ActiveForm
DoCmd.SelectObject acForm, stDocName, True
DoCmd.PrintOut
DoCmd.SelectObject acForm, MyForm.Name, False

Exit_Print_Click:
Exit Sub

Err_Print_Click:
MsgBox Err.Description
Resume Exit_Print_Click

End Sub
Private Sub Command85_Click()
On Error GoTo Err_Command85_Click

Dim stDocName As String

stDocName = "Oustanding report no part or completed entered"
DoCmd.OpenQuery stDocName, acNormal, acEdit

Exit_Command85_Click:
Exit Sub

Err_Command85_Click:
MsgBox Err.Description
Resume Exit_Command85_Click

End Sub
Private Sub NewRecord_Click()
On Error GoTo Err_NewRecord_Click


DoCmd.GoToRecord , , acNewRec

Exit_NewRecord_Click:
Exit Sub

Err_NewRecord_Click:
MsgBox Err.Description
Resume Exit_NewRecord_Click

End Sub

Private Sub Scrapped_Mfg_cost_BeforeUpdate(Cancel As Integer)

End Sub
 
Janet,

This is just air code but I would probably change your Print_Click code like
so

**************
Private Sub Print_Click()
On Error GoTo Err_Print_Click

Dim stDocName As String
Dim MyForm As Form
Dim intQty As Integer

intQty = InputBox("How many copies would you like printed?")

stDocName = "Input Form 2"
Set MyForm = Screen.ActiveForm
DoCmd.SelectObject acForm, stDocName, True
DoCmd.PrintOut , , , , intQty
DoCmd.SelectObject acForm, MyForm.Name, False

Exit_Print_Click:
Exit Sub

Err_Print_Click:
MsgBox Err.Description
Resume Exit_Print_Click

End Sub
************

The printout input variable are

'expression.PrintOut(PrintRange, PageFrom, PageTo, PrintQuality, Copies,
CollateCopies)

therefore you should simply need to input an integer value as your 5th input
variable to specify the number of copies.

Try it out and let me know,

Daniel
 
Janet,

This is just air code but I would probably change your Print_Click code like
so

**************
Private Sub Print_Click()
On Error GoTo Err_Print_Click

Dim stDocName As String
Dim MyForm As Form
Dim intQty As Integer

intQty = InputBox("How many copies would you like printed?")

stDocName = "Input Form 2"
Set MyForm = Screen.ActiveForm
DoCmd.SelectObject acForm, stDocName, True
DoCmd.PrintOut , , , , intQty
DoCmd.SelectObject acForm, MyForm.Name, False

Exit_Print_Click:
Exit Sub

Err_Print_Click:
MsgBox Err.Description
Resume Exit_Print_Click

End Sub
************

The printout input variable are

'expression.PrintOut(PrintRange, PageFrom, PageTo, PrintQuality, Copies,
CollateCopies)

therefore you should simply need to input an integer value as your 5th input
variable to specify the number of copies.

Try it out and let me know,

Daniel
































- Show quoted text -

Thanks Daniel

I will have a go
 
Janet,

This is just air code but I would probably change your Print_Click code like
so

**************
Private Sub Print_Click()
On Error GoTo Err_Print_Click

Dim stDocName As String
Dim MyForm As Form
Dim intQty As Integer

intQty = InputBox("How many copies would you like printed?")

stDocName = "Input Form 2"
Set MyForm = Screen.ActiveForm
DoCmd.SelectObject acForm, stDocName, True
DoCmd.PrintOut , , , , intQty
DoCmd.SelectObject acForm, MyForm.Name, False

Exit_Print_Click:
Exit Sub

Err_Print_Click:
MsgBox Err.Description
Resume Exit_Print_Click

End Sub
************

The printout input variable are

'expression.PrintOut(PrintRange, PageFrom, PageTo, PrintQuality, Copies,
CollateCopies)

therefore you should simply need to input an integer value as your 5th input
variable to specify the number of copies.

Try it out and let me know,

Daniel
































- Show quoted text -

Hi Daniel


I must be doing something wrong can't seem to get it to work.

The report I have done has input boxes first input box is qty, next is
batch no then there is a part no. So i enter 3 forms of criteria.
But I cannot seem to get your code to work nothing happens!! help

Many thanks

J
 
Hi Daniel

I must be doing something wrong can't seem to get it to work.

The report I have done has input boxes first input box is qty, next is
batch no then there is a part no. So i enter 3 forms of criteria.
But I cannot seem to get your code to work nothing happens!! help

Many thanks

J- Hide quoted text -

- Show quoted text - Hi Daniel

Can I put a command button on a report and put code behind that to
print??????


Many thanks

J
 
Hi Janet,

There is a nifty bit of code to be found here:
http://www.peterssoftware.com/ls.htm

It's Peter's Software Label Saver. It not only allows you to input the number
of copies but where on a page it should start (hence Label Saver). The one
thing that isn't made clear in the instructions is that you must design the
labels yourself. That is to say you design a report with the fields you need on
the label. You have to make sure it is sized just right for the labels you're
using. You set the Height in the report Detail, the Width in the report's
properties and columns and margins in Page Setup. Once you have your label
designed and this code put in all the places mentioned in the instructions it
works great.

Hope this helps,
RD
 

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

Back
Top