Results 1 to 3 of 3
  1. #1
    Join Date
    Oct 2010

    Unanswered: How to use a text box to trigger the number to print

    My question is how to use an unbound text box to accept an input number which will act as the number of copies to be printed when one presses the print command button.

    The Access objective is to have the Report picture that of the two boxes, to be constantly displayed on a warehouse computer monitor screen: whereby, the data input person will only need to type in the item charters (e.g., 1xy) and description (e.g. Bland) along with the number of labels (e.g. 4) to be automatically printed out by the label machine.

    One problem is that the number labels to be printed will always change, along with the label depicting the item and description. The major problem which is also the obvious is that we do not have an Access expert to fix this problem. This is a nonprofit venture, thus, we use what resources we have or do the best we can until we have proper resources and time to address the situation fully. Until such time, I am using Access 2002…and I must admit that I am using this program very badly, that is previously I have not venture off into areas that require any type of programing use…

    I have a Table called Tb2Num

    This Table has one field called How_Many.

    This Field has sequential numbers from 1 to 100.

    I have a Query called Ops1

    which is based on the table called Tb2Num,

    This Field is called How_Many

    (This is normally where I stop, in that my Access skills are at the max and I simply use a built in report)

    The sequential numbers from one to 100.

    I have placed the following in the criteria selection in this query that reads:


    I have a Form (based on the Query—Ops1) called Ops Form

    that has two unbound boxes One called Item

    the other is called Description

    with a text box called Number_To_Print

    and a Print Button

    that I added by using the Wizard

    I have a Report called Report 1x

    that has two boxes one box called Item

    and the other boxes is called Description.

    The information that I have placed in the form is not being transfer to the report boxes and pressing the print button only prints out the form, just one copy.

    I have inserted such as DoCmd.OpenReport "LabelShopOrderQueryGel", acViewPreview

    'create the message box

    Dim PRNT As Integer

    'PRNT = MsgBox("Print" & "[Forms]![LabelValues]![NumLabelsGel].Value" & " Labels?", vbQuestion + vbYesNo + vbDefaultButton1, "Question")

    Private Sub Print_Report1x_Click()

    On Error GoTo Err_Print_Report1xyz_Click
    Dim MyWhereCondition As String
    MyWhereCondition = "How_Many = " & Me.How_Many
    DoCmd.OpenReport "Opss", acViewPreview, , MyWhereCondition
    Exit Sub
    MsgBox Err.Description
    Resume Exit_Print_Report1x_Click
    End Sub

    I have no idea where this statement is to go:

    PRNT = MsgBox("Print "&CStr([Forms]![LabelValues]![NumLabelsGel].Value) &" Labels?", vbQuestion + vbYesNo + vbDefaultButton1, "Question")

    As you might have guessed, I have obtained and mis-used information that I had gathered from the Web, and evidently, I have placed the information in either the wrong location or in the wrong order in the Access Form or Report or both and/or called a form a report or a report a form and thus I am not receiving the results, that of an operator being able to print labels by placing information onto a screen.

    Any and all help is needed--such as when we print the Form we see the Number_To_Print box, we only need the Label with the Item and Description, which we do see in the Report, but the report and the Form does not print the number of copies that we requested, only one copy is produce when we hit the print command button.

    I am sure there is a better way in which to express this lengthy concern in a shorter request --- Thank you for your understanding and willingness to help...

  2. #2
    Join Date
    Jan 2009
    Kerala, India

    How to use a text box to trigger the number to print

    1. Open a new Standard Module in your Database.
    2. Copy the following Code into the Module and Save.
    Private Type str_DEVMODE
        RGB As String * 94
    End Type
    Private Type type_DEVMODE
        strDeviceName As String * 16
        intSpecVersion As Integer
        intDriverVersion As Integer
        intSize As Integer
        intDriverExtra As Integer
        lngFields As Long
        intOrientation As Integer
        intPaperSize As Integer
        intPaperLength As Integer
        intPaperWidth As Integer
        intScale As Integer
        intCopies As Integer
        intDefaultSource As Integer
        intPrintQuality As Integer
        intColor As Integer
        intDuplex As Integer
        intResolution As Integer
        intTTOption As Integer
        intCollate As Integer
        strFormName As String * 16
        lngPad As Long
        lngBits As Long
        lngPW As Long
        lngPH As Long
        lngDFI As Long
        lngDFr As Long
    End Type
    Public Sub PaperAndOrient(ByVal strName As String, myCopies as integer)
        Const DM_PORTRAIT = 1
        Const DM_LANDSCAPE = 2
        Const DM_PAPERSIZE = 9
        Dim DevString As str_DEVMODE
        Dim DM As type_DEVMODE
        Dim strDevModeExtra As String
        Dim rpt As Report
        ' Opens report in Design view.
        DoCmd.OpenReport strName, acDesign
        Set rpt = Reports(strName)
        If Not IsNull(rpt.PrtDevMode) Then
            strDevModeExtra = rpt.PrtDevMode
            DevString.RGB = strDevModeExtra
            LSet DM = DevString
            DM.lngFields = DM.lngFields Or DM.intOrientation
            ' Initialize fields.
            DM.intPaperSize = DM_PAPERSIZE
            DM.intCopies = myCopies
            If DM.intOrientation = DM_LANDSCAPE Then
                DM.intOrientation = DM_PORTRAIT
            End If
            ' Update property.
            LSet DevString = DM
            Mid(strDevModeExtra, 1, 94) = DevString.RGB
            rpt.PrtDevMode = strDevModeExtra
        End If
        DoCmd.Close acReport, strName, acSaveYes
        DoCmd.OpenReport strName, acViewPreview
        Set rpt = Nothing
    End Sub
    3. To Run your Report from the Command Button Click Call the Function PaperAndOrient() like the example below:

    Private Sub Print_Report1x_Click()
       PaperAndOrient "Opss", me![How_Many]
    End Sub
    NB: If your Report Design is LANDSCAPE Mode then it will change to PORTRAIT.

    You can change this condition by modifying the following lines in the code:

    If DM.intOrientation = DM_LANDSCAPE Then
                DM.intOrientation = DM_PORTRAIT
    End If (Learn MS-Access Tips & Tricks)
    Learn Advanced MS-Access Programming with sample VBA Code.

    All responses are based on Access 2003/2007

  3. #3
    Join Date
    Oct 2010

    Solution:How to use a text box to trigger the number to print


    First my sincere thank you for taking the time to go through my not well written request.

    Thank you for sharing with me your professional time and your professional experiences and insight into how best to gain the proper solution to my request.

    Thank you for being willing to teach me, without belittling me, that I will have to learn a lot more about this Program, before I can began to understand its full usages.

    Sorry for being redundant: At the moment, I am simply overwhelmed by the complexity require in running the procedures you have given to me and the willingness of someone taking the time to help me.

    I am now off to implement the procedures: I will post my results,


Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts