Results 1 to 4 of 4

Thread: Printing help please...

  1. #1

    Thread Starter
    New Member
    Join Date
    May 2005
    Posts
    8

    Unhappy Printing help please...

    I am trying to make a label print automatically when a membership card is scanned. The scan event needs to kick off the print of the label. I don't want to create a button that needs to be pushed to print the label. I need it to happen automatically. In our database we have an after scan code listed below. Can anyone tell me where I should place the print code and what it should be? I tried to insert this:

    Printer.Print "This is a test"
    Printer.EndDoc

    But, I couldn't even get it to print that. I will be inserting to attributes out of our database onto the labels that will print.


    'This event occurs immediately after a card has been scanned but before any processing has taken place.

    Public Sub MembershipScanning_CardScanned(oMemScanDisplay As Object, ByVal sScannedData As String, ByRef lMembershipID As Long, ByRef lMembershipTableID As Long, ByRef lMembershipCardID As Long, ByRef bCancelDefault As Boolean)
    'oMemScanDisplay : Reference to the membership scanning display dataobject
    'sScannedData : Indicates the data that was scanned
    'lMembershipID : Allows you to return the MembershipID to be displayed
    'lMembershipTableID : Allows you to return the MembershipTableID to be displayed
    'lMembershipCardID : Allows you to return the MembershipCardID to be displayed
    'bCancelDefault : Indicates that the system should skip the default processing of the scanned data and operate instead on the IDs returned from this event

    Dim oScanDisplay As IBBMemScanDisplay

    On Error GoTo ErrHandler

    Set oScanDisplay = oMemScanDisplay

    If Not oScanDisplay Is Nothing Then
    '< place your custom CardScanned code here >
    End If

    Set oScanDisplay = Nothing

    On Error GoTo 0

    Exit Sub

    ErrHandler:
    Dim sErr As String
    sErr = Err.Description
    On Error GoTo 0
    '< place your custom error handling code here >
    MsgBox "Error processing MembershipScanning_BeforeDisplay : " & sErr

    Set oScanDisplay = Nothing

    Exit Sub

    End Sub

    'This event occurs after the card has been scanned and the information is displayed
    Public Sub MembershipScanning_AfterDisplay(oMemScanDisplay As Object)
    'oMemScanDisplay : Reference to the membership scanning display dataobject

    Dim oScanDisplay As IBBMemScanDisplay

    On Error GoTo ErrHandler

    Set oScanDisplay = oMemScanDisplay

    Begin:

    Printer.Orientation = vbPRORLandscape
    Printer.Font = "Courier new" ' "r_ansi" '"TIMES NEW ROMAN"
    Printer.FONTBOLD = True
    Printer.FONTSIZE = 10
    Application.VBE.VBProjects(1).Description = "Hot Sauce"
    Debug.Print Application.VBE.VBProjects(1).Description
    Printer
    Printer.Print "This is a test"
    Printer.EndDoc


    If Not oScanDisplay Is Nothing Then

    End If

    Set oScanDisplay = Nothing

    On Error GoTo 0

    Exit Sub

    ErrHandler:
    Dim sErr As String
    sErr = Err.Description
    On Error GoTo 0
    '< place your custom error handling code here >
    MsgBox "Error processing MembershipScanning_AfterDisplay : " & sErr

    Set oScanDisplay = Nothing

    Exit Sub

    End Sub

  2. #2
    Addicted Member
    Join Date
    Jan 2002
    Location
    Glasgow, Scotland
    Posts
    202

    Re: Printing help please...

    adding tags to make it easier to read

    VB Code:
    1. Public Sub MembershipScanning_CardScanned(oMemScanDisplay As Object, ByVal sScannedData As String, ByRef lMembershipID As Long, ByRef lMembershipTableID As Long, ByRef lMembershipCardID As Long, ByRef bCancelDefault As Boolean)
    2. 'oMemScanDisplay : Reference to the membership scanning display dataobject
    3. 'sScannedData : Indicates the data that was scanned
    4. 'lMembershipID : Allows you to return the MembershipID to be displayed
    5. 'lMembershipTableID : Allows you to return the MembershipTableID to be displayed
    6. 'lMembershipCardID : Allows you to return the MembershipCardID to be displayed
    7. 'bCancelDefault : Indicates that the system should skip the default processing of the scanned data and operate instead on the IDs returned from this event
    8.  
    9. Dim oScanDisplay As IBBMemScanDisplay
    10.  
    11. On Error GoTo ErrHandler
    12.  
    13. Set oScanDisplay = oMemScanDisplay
    14.  
    15. If Not oScanDisplay Is Nothing Then
    16. '< place your custom CardScanned code here >
    17. End If
    18.  
    19. Set oScanDisplay = Nothing
    20.  
    21. On Error GoTo 0
    22.  
    23. Exit Sub
    24.  
    25. ErrHandler:
    26. Dim sErr As String
    27. sErr = Err.Description
    28. On Error GoTo 0
    29. '< place your custom error handling code here >
    30. MsgBox "Error processing MembershipScanning_BeforeDisplay : " & sErr
    31.  
    32. Set oScanDisplay = Nothing
    33.  
    34. Exit Sub
    35.  
    36. End Sub
    37.  
    38. 'This event occurs after the card has been scanned and the information is displayed
    39. Public Sub MembershipScanning_AfterDisplay(oMemScanDisplay As Object)
    40. 'oMemScanDisplay : Reference to the membership scanning display dataobject
    41.  
    42. Dim oScanDisplay As IBBMemScanDisplay
    43.  
    44. On Error GoTo ErrHandler
    45.  
    46. Set oScanDisplay = oMemScanDisplay
    47.  
    48. Begin:
    49.  
    50. Printer.Orientation = vbPRORLandscape
    51. Printer.Font = "Courier new" ' "r_ansi" '"TIMES NEW ROMAN"
    52. Printer.FONTBOLD = True
    53. Printer.FONTSIZE = 10
    54. Application.VBE.VBProjects(1).Description = "Hot Sauce"
    55. Debug.Print Application.VBE.VBProjects(1).Description
    56. Printer
    57. Printer.Print "This is a test"
    58. Printer.EndDoc
    59.  
    60.  
    61. If Not oScanDisplay Is Nothing Then
    62.  
    63. End If
    64.  
    65. Set oScanDisplay = Nothing
    66.  
    67. On Error GoTo 0
    68.  
    69. Exit Sub
    70.  
    71. ErrHandler:
    72. Dim sErr As String
    73. sErr = Err.Description
    74. On Error GoTo 0
    75. '< place your custom error handling code here >
    76. MsgBox "Error processing MembershipScanning_AfterDisplay : " & sErr
    77.  
    78. Set oScanDisplay = Nothing
    79.  
    80. Exit Sub
    81.  
    82. End Sub
    if you fail to plan, you plan to fail

  3. #3

    Thread Starter
    New Member
    Join Date
    May 2005
    Posts
    8

    Re: Printing help please...

    Thank you!

  4. #4
    Ex-Super Mod RobDog888's Avatar
    Join Date
    Apr 2001
    Location
    LA, Calif. Raiders #1 AKA:Gangsta Yoda™
    Posts
    60,709

    Re: Printing help please...

    Your doing this in VB6 or in an Office app?
    VB/Office Guru™ (AKA: Gangsta Yoda®)
    I dont answer coding questions via PM. Please post a thread in the appropriate forum.

    Microsoft MVP 2006-2011
    Office Development FAQ (C#, VB.NET, VB 6, VBA)
    Senior Jedi Software Engineer MCP (VB 6 & .NET), BSEE, CET
    If a post has helped you then Please Rate it!
    Reps & Rating PostsVS.NET on Vista Multiple .NET Framework Versions Office Primary Interop AssembliesVB/Office Guru™ Word SpellChecker™.NETVB/Office Guru™ Word SpellChecker™ VB6VB.NET Attributes Ex.Outlook Global Address ListAPI Viewer utility.NET API Viewer Utility
    System: Intel i7 6850K, Geforce GTX1060, Samsung M.2 1 TB & SATA 500 GB, 32 GBs DDR4 3300 Quad Channel RAM, 2 Viewsonic 24" LCDs, Windows 10, Office 2016, VS 2019, VB6 SP6

Posting Permissions

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



Click Here to Expand Forum to Full Width