By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
424,984 Members | 1,086 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 424,984 IT Pros & Developers. It's quick & easy.

Message Box To Ask How Many Copies

P: 14
I have a report that is a label report, I want a message box to come up that asks how many of the Labe they want. This is the code so far
Expand|Select|Wrap|Line Numbers
  1. Private Sub Command32_Click()
  2. 'Open report in Preview mode
  3.     DoCmd.OpenReport "Labels Part Labels Dymo", acViewPreview
  4. 'Print out specified number of report copies
  5.     DoCmd.PrintOut , , , , 2
  6. End Sub
Where the number 2 is on the DoCmd.PrintOut I want a message box to come up and ask how many labels do you want to print
Sep 16 '08 #1
Share this Question
Share on Google+
3 Replies


Delerna
Expert 100+
P: 1,134
something like this
Expand|Select|Wrap|Line Numbers
  1. n=inputbox("Please enter the number of copies")
  2.  
Sep 16 '08 #2

NeoPa
Expert Mod 15k+
P: 31,347
If this is being executed from a form anyway, I would consider adding an unbound TextBox control onto your form with a default value of 1. If it were called txtcount, then your code might look like :
Expand|Select|Wrap|Line Numbers
  1. Private Sub Command32_Click()
  2. 'Open report in Preview mode
  3.     DoCmd.OpenReport "Labels Part Labels Dymo", acViewPreview
  4. 'Print out specified number of report copies
  5.     DoCmd.PrintOut , , , , Me.txtCount
  6. End Sub
Sep 16 '08 #3

ADezii
Expert 5K+
P: 8,619
You should have tight control over the Number of Copies to Print, so as to avoid an inadvertant entry of 99 for Number o Copies. I personally feel that the Number of Copies to Print should be controlled via a Limited-to-List Combo Box.
  1. Create a Combo Box and name it cboCopies.
  2. Set the following Properties to allow a Maximum Number of 10 for the Copies, and do not allow the User to enter any number not contained within the Combo Box.
    • Row Source Type = Value List
    • RowSource = 1;2;3;4;5;6;7;8;9;10
    • Limit to List = Yes
  3. Place the following code wherever appropriate:
    Expand|Select|Wrap|Line Numbers
    1. If IsNull(Me![cboCopies]) Then
    2.   MsgBox "You mujst enter the Number of Copies to Print", vbExclamation, "No Copies"
    3.   Me![cboCopies].SetFocus       'Set Focus to Combo Box
    4.   Me![cboCopies].Dropdown       'Drop it Down
    5. Else
    6.   'Open report in Preview mode
    7.   DoCmd.OpenReport "Labels Part Labels Dymo", acViewPreview
    8.   'Print out specified number of report copies
    9.     DoCmd.PrintOut , , , , Me![cboCopies]
    10. End If
    11.  
Sep 16 '08 #4

Post your reply

Sign in to post your reply or Sign up for a free account.