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

Need Message Box on Print

P: 14
I have a label that needs to print out when a part comes in, but I want a message box to pop up to ask how many copies of the label do they want to print. This is my code so far. Where the Docmd.Print is, I have 2 for the copies, but I want a message box that the user will enter how many they want.

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
Sep 16 '08 #1
Share this Question
Share on Google+
4 Replies

Expert 100+
P: 849
This is in the wrong place, perhaps you wanted the Visual Basic forum?
Sep 16 '08 #2

Expert Mod 15k+
P: 16,027
Moved to the Visual Basic forum. The Feedback forum is not for technical questions. Please use the most relevant forum for your question. Also remember to enclose your code in code tags.

Sep 16 '08 #3

P: 556
is this an Access Database you have or visual basic, because a "DoCmd" is in MS Access i have never seen it done in visual basic 6

Sep 16 '08 #4

P: 93
Please specify what kind of VB are you using (MS Office or VB IDE).

Choices I would implement:
1) Create your custom dialog box, then create a PUBLIC variable (Public copyNumber as Integer), and then pass the number of copies to the main window through the global variable (the one you set to Public) after you showed the Dialog form and got some input from the user.
2) Set a variable and use the InputBox("","") function to get a value for the variable.

Supposing you don't have VB 6 (IDE) and Office follows most of VB 5/6:

Expand|Select|Wrap|Line Numbers
  1. Public copyNumber as Integer
  2. Private Sub Command32_Click()
  3. 'Open report in Preview mode
  4.     DoCmd.OpenReport "Labels Part Labels Dymo", acViewPreview
  5. 'Ask for # of copies
  7. 'frmAsk is the custom dialog form created for option 1.
  8. 'If you can't use .show(), try .visible = true
  9. 'Print out specified number of report copies
  10. 'Pass the number of copies
  11.     DoCmd.PrintOut , , , , copyNumber
  12. End sub
Supposing you have VB IDE:

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. 'Ask for # of copies
  5. Dim i as Integer
  6. 'The function InputBox is in VB 6 but I don't know if it is in VB for Office (try it anyways)
  7. i = InputBox("Replace with Prompt", "Replace with Title for the Dialog Box")
  8. 'Print out specified number of report copies
  9. 'Pass the number of copies
  10.     DoCmd.PrintOut , , , , i
  11. End sub
I really hope ou got your answer.
Sep 17 '08 #5

Post your reply

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