I have a form that autopopulates a barcode number into the form field upon opening the form. The user then selects a button that will will call and print the barcode through another application. I only want to print the field and not the entire record. Will the following work? The other application has all the printing parms set so I do not have to select the printing.
++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Option Compare Database
Dim MyApp As Object
Dim lblPercentDone As Object
Option Explicit
' The 'WithEvents' keyword specifies that MyDoc will provide events.
Private WithEvents MyDoc As LabelManager2.Document
Private mblnCancel As Boolean
Private Sub Form_Load()
Set MyApp = New LabelManager2.Application
Set MyDoc = MyApp.Documents.Add("My Documents\Mylan\test.lab")
MyApp.EnableEvents = True
End Sub
Private Sub Print_Barcode_Click()
mblnCancel = False
lblPercentDone.Caption = "0%"
lblPercentDone.Refresh
Call MyDoc.LongTask(10, 0.5)
If Not mblnCancel Then lblPercentDone.Caption = 100
End Sub
Private Sub MyDoc_BeginPrinting(ByVal strDocName As String)
On Error GoTo Err_Print_Barcode_Click
Dim strWhere As String
strDocName = MyApp
strWhere = "[Barcode Number]=" & Me![Barcode Number]
DoCmd.PrintOut strDocName, strWhere
Exit_Print_Barcode_Click:
Exit Sub
Err_Print_Barcode_Click:
MsgBox Err.Description
Resume Exit_Print_Barcode_Click
End Sub
Private Sub MyDoc_ProgressPrinting(ByVal Percent As Integer, Cancel As Integer)
lblPercentDone.Caption = CInt(100 * Percent) & "%"
DoEvents
If mblnCancel Then Cancel = True
End Sub
Private Sub Command2_Click()
mblnCancel = True
End Sub
Homer: But every time I learn something new, it pushes out something old! Remember that time I took a home wine-making course and forgot how to drive?
Marge Simpson: That's because you were drunk!
Homer: And how.
++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Option Compare Database
Dim MyApp As Object
Dim lblPercentDone As Object
Option Explicit
' The 'WithEvents' keyword specifies that MyDoc will provide events.
Private WithEvents MyDoc As LabelManager2.Document
Private mblnCancel As Boolean
Private Sub Form_Load()
Set MyApp = New LabelManager2.Application
Set MyDoc = MyApp.Documents.Add("My Documents\Mylan\test.lab")
MyApp.EnableEvents = True
End Sub
Private Sub Print_Barcode_Click()
mblnCancel = False
lblPercentDone.Caption = "0%"
lblPercentDone.Refresh
Call MyDoc.LongTask(10, 0.5)
If Not mblnCancel Then lblPercentDone.Caption = 100
End Sub
Private Sub MyDoc_BeginPrinting(ByVal strDocName As String)
On Error GoTo Err_Print_Barcode_Click
Dim strWhere As String
strDocName = MyApp
strWhere = "[Barcode Number]=" & Me![Barcode Number]
DoCmd.PrintOut strDocName, strWhere
Exit_Print_Barcode_Click:
Exit Sub
Err_Print_Barcode_Click:
MsgBox Err.Description
Resume Exit_Print_Barcode_Click
End Sub
Private Sub MyDoc_ProgressPrinting(ByVal Percent As Integer, Cancel As Integer)
lblPercentDone.Caption = CInt(100 * Percent) & "%"
DoEvents
If mblnCancel Then Cancel = True
End Sub
Private Sub Command2_Click()
mblnCancel = True
End Sub
Homer: But every time I learn something new, it pushes out something old! Remember that time I took a home wine-making course and forgot how to drive?
Marge Simpson: That's because you were drunk!
Homer: And how.