Results 1 to 3 of 3

Thread: Access VBA Print QR Code

  1. #1

    Thread Starter
    Fanatic Member mateo107's Avatar
    Join Date
    Jan 2005
    Posts
    547

    Access VBA Print QR Code

    Hi All,

    I'm got a simple Asset Tag tracking Access Database with a simple form the user fills out that includes Make/Model/etc., information. I need to generate QR codes for the Asset Tag information, so I found this code to use google's API to get a QR code to show in a WebBrowser control.

    I need to print the QR code, along with the Asset Tag number (above or below the QR code) on a small label that's 1x1 (Page Setup shows this as 30332 1 in x 1 in). What's the best way to accomplish this? Save the img and then create a button that creates a report with the pre-defined info?

    Here's what I have now to get my QR code into my form dynamically.

    Code:
    Me.AssetTag.Value = EquipType.Value & "-" & Year(Me.PurchaseDate.Value) & Format(Month(Me.PurchaseDate.Value), "00") & Format(Day(Me.PurchaseDate.Value), "00") & Format(Right(Str(Me.PurchasePrice.Value), Len(Str(Me.PurchasePrice.Value)) - 1), "000000") & "-" & Format(Me.ID.Value, "000000")
    
    'Create QR Code Using Google API
    
    Dim Size As Integer
    Dim Text As String
    Dim url As String
    Size = 150
    Text = Me.AssetTag.Value
    Text = Replace(Text, " ", "%20")
    url = "http://chart.apis.google.com/chart?chs=" & Size & "x" & Size & "&cht=qr&chld=H|0&chl=" & Text
    WebBrowser7.Navigate (url)
    Currently, I am using this code just to print the webbrowser control, but I have to go into page setup each time and set the page size and margins to 0, which is a pain, for EACH label...

    Code:
    WebBrowser7.ExecWB OLECMDID_PRINTPREVIEW, OLECMDEXECOPT_DODEFAULT 'PRINT Dialog Box


    -Matthew-

  2. #2
    PowerPoster jdc2000's Avatar
    Join Date
    Oct 2001
    Location
    Idaho Falls, Idaho USA
    Posts
    2,398

  3. #3
    PowerPoster
    Join Date
    Dec 2004
    Posts
    25,618

    Re: Access VBA Print QR Code

    possibly you could manually add a printer, a copy of the existing printer (give it some meaningful name), set all the defaults as required, then your code could print to that printer, probably using setdefaultprinter API then change back after printing
    i do my best to test code works before i post it, but sometimes am unable to do so for some reason, and usually say so if this is the case.
    Note code snippets posted are just that and do not include error handling that is required in real world applications, but avoid On Error Resume Next

    dim all variables as required as often i have done so elsewhere in my code but only posted the relevant part

    come back and mark your original post as resolved if your problem is fixed
    pete

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