Results 1 to 4 of 4
  1. #1
    mejia.j88 is offline Competent Performer
    Windows 7 64bit Access 2007
    Join Date
    Nov 2011
    Location
    california
    Posts
    228

    Need advice on report printing program


    Hello all,

    I have a form that is used to enter a work order. A work order contains various "stacks". In my form, the operator chooses the Work Order, and enters how many stacks are being built that day. The form then saves multiple records depending on stacks built THEN it should print a label for each dash number.

    An example of how it would save is: W1234-1 then new record for W1234-2, new record for W1234-3 etc, until the dash number reaches the numbers of stacks built.

    I have found this code in a database used here at work (might have been taken off the net):
    Code:
     Private Function PrintLabels()      Dim Show_Box As Boolean
          Dim Response As Variant
          Dim i As Integer
          Dim strWhereID As String
          
          ' Set the Show_Dialog variable to True.
          Show_Box = True
    
    
          ' Begin While loop.
          While Show_Box = True
    
    
             ' Show the input box.
             Response = InputBox("Enter the number of labels to print or press Cancel to skip printing.", "Label Printing", 1)
    
    
             ' See if Cancel was pressed.
             If Response = "" Then
    
    
                ' If Cancel was pressed,
                ' break out of the loop.
                Show_Box = False
             Else
                ' Test Entry to find out if it is numeric.
                If IsNumeric(Response) = True Then
                    For i = 1 To Response
                    strID = "[ID]=" & Me.ID
                        DoCmd.OpenReport "SilverLabels", acViewPreview, , strWhereID
                    Next i
                   Show_Box = False
                Else
                   ' If the entry was wrong, show an error message.
                   MsgBox "Please Enter Numbers Only"
                End If
             End If
          ' End the While loop.
          Wend
    End Function
    my form is not bound, i wanted to do everything with coding (for practice). Currently, it does not print and gives me a pop up for Enter ID.

    any suggestions on how to go about this?

    i hope my message is clear, i can explain further if needed.

    Thank you all in advanced.

  2. #2
    pbaldy's Avatar
    pbaldy is offline Who is John Galt?
    Windows XP Access 2007
    Join Date
    Feb 2010
    Location
    Nevada, USA
    Posts
    22,521
    If it's prompting you, either ID is not a field in the report's record source or not a control on the form.
    Paul (wino moderator)
    MS Access MVP 2007-2019
    www.BaldyWeb.com

  3. #3
    JrMontgom is offline Competent Performer
    Windows Vista Access 2010 32bit
    Join Date
    Sep 2012
    Location
    Vero Beach, FL USA
    Posts
    124
    It appears in your DoCmd code you are suing a variable named strWhereID whereas you have the string variable named strID hence it thinks you want to enter a parameter. You just need to change the variable names

  4. #4
    pbaldy's Avatar
    pbaldy is offline Who is John Galt?
    Windows XP Access 2007
    Join Date
    Feb 2010
    Location
    Nevada, USA
    Posts
    22,521
    Good catch, I didn't notice that.
    Paul (wino moderator)
    MS Access MVP 2007-2019
    www.BaldyWeb.com

Please reply to this thread with any new information or opinions.

Similar Threads

  1. Advice on how to Build a Specific Report
    By cbgroves in forum Reports
    Replies: 12
    Last Post: 12-12-2011, 08:27 AM
  2. Need Report Advice
    By Kevo in forum Reports
    Replies: 1
    Last Post: 08-04-2011, 09:22 PM
  3. program a text box in a report!
    By NateHaze in forum Programming
    Replies: 1
    Last Post: 06-07-2011, 05:55 AM
  4. Program a 30-day trial into my Access Program?
    By genghiscomm in forum Programming
    Replies: 1
    Last Post: 05-26-2011, 02:14 PM
  5. Report printing
    By Andrevw in forum Reports
    Replies: 1
    Last Post: 01-16-2011, 06:08 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Other Forums: Microsoft Office Forums