Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations biv343 on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Passing a controls numeric vaule to a printer 1

Status
Not open for further replies.

DrillMonkey

Technical User
Sep 29, 2006
64
US
Hello,

I have a control on my from named TotalParcels, I want to pass the value of the control to a Dymo Labelwriter.. If the user types the number 5 in the control I want the Dymo to print 5 labels. I want to put this code behind my print button..so when I run my report (on my laser printer) I also get the corresponding number of labels printed on the Dymo labelwriter..
 
Something like the below perhaps? I didn't complete the openreport line.


Code:
Dim L as Long
For L = 1 To Me!txtLabelCOunt
    Docmd.openreport ....
Next L
 
Thanks for responding lameid,

this is the code I'm using behind my print button..
*********************************************************
Private Sub Command75_Click()
Dim strWhere As String

If Me.Dirty Then 'Save any edits.
Me.Dirty = False
End If

If Me.NewRecord Then 'Check there is a record to print
MsgBox "Select a record to print"
Else
strWhere = "[MemoID] = " & Me.[MemoID]
DoCmd.OpenReport "MemoRpt", acViewNormal, , strWhere
End If
End Sub
************************************************************
can I use your suggestion after the strWhere statement? sorry but I'm not very proficient in Access..
 
Code:
Private Sub Command75_Click()
Dim strWhere As String
Dim L as Long

    If Me.Dirty Then    'Save any edits.
        Me.Dirty = False
    End If

    If Me.NewRecord Then 'Check there is a record to print
        MsgBox "Select a record to print"
    Else
        strWhere = "[MemoID] = " & Me.[MemoID]
        For L = 1 To Me!txtLabelCOunt
             DoCmd.OpenReport "MemoRpt", acViewNormal, , strWhere
        Next L
    End If
End Sub

Note that txtLabelCOunt is the control having the number of labels you want to print.
 
Lameid,

Works like a charm! I have only set it up for laserjet at the momment, with a dummy report for the Dymo labelwriter but I can tell its going to work many thanks!
 
instead of opening the report x # of times

try my method

create a table called digits with 1 field digitid

enter in to the table number from 1 to xxxxx

use this sql as the recordsource of the report
Code:
select ........
from tablename ,digits
where digits<=forms!formname!TotalParcels



 
FYI, Pwise's solution would likely be faster.

Although you should probably Group by the digits field and set the force new page property to after section.

Additionally, if you use page numbers, you may have to reset them in code.

Also you have to have your table populated with the maximum number of prints to ever be made.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top