Need Message Box on Print

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • MicMic
    New Member
    • Mar 2007
    • 14

    Need Message Box on Print

    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.

    [CODE=vb]Private Sub Command32_Click ()
    'Open report in Preview mode
    DoCmd.OpenRepor t "Labels Part Labels Dymo", acViewPreview
    'Print out specified number of report copies
    DoCmd.PrintOut , , , , 2
    End Sub[/CODE]
    Last edited by acoder; Sep 16 '08, 10:21 PM. Reason: Added [code] tags
  • Laharl
    Recognized Expert Contributor
    • Sep 2007
    • 849

    #2
    This is in the wrong place, perhaps you wanted the Visual Basic forum?

    Comment

    • acoder
      Recognized Expert MVP
      • Nov 2006
      • 16032

      #3
      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.

      Moderator.

      Comment

      • lee123
        Contributor
        • Feb 2007
        • 556

        #4
        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

        lee123

        Comment

        • kiseitai2
          New Member
          • Jul 2007
          • 93

          #5
          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:

          Code:
          Public copyNumber as Integer
          Private Sub Command32_Click()
          'Open report in Preview mode
              DoCmd.OpenReport "Labels Part Labels Dymo", acViewPreview
          'Ask for # of copies
          frmAsk.show()
          'frmAsk is the custom dialog form created for option 1.
          'If you can't use .show(), try .visible = true
          'Print out specified number of report copies
          'Pass the number of copies
              DoCmd.PrintOut , , , , copyNumber
          End sub
          Supposing you have VB IDE:

          Code:
          Private Sub Command32_Click()
          'Open report in Preview mode
              DoCmd.OpenReport "Labels Part Labels Dymo", acViewPreview
          'Ask for # of copies
          Dim i as Integer
          'The function InputBox is in VB 6 but I don't know if it is in VB for Office (try it anyways)
          i = InputBox("Replace with Prompt", "Replace with Title for the Dialog Box")
          'Print out specified number of report copies
          'Pass the number of copies
              DoCmd.PrintOut , , , , i
          End sub
          I really hope ou got your answer.

          Comment

          Working...