I'm trying to create QR codes in a report.
The report is printed as a label. I found how to create a QR code using the google API link in a FORM. (Webvrowser control set to google location)
so the image does diplay in FORM1.. however, to print it i need to somehow get the image to load in the report.
i can see that someone has done something similar here:-
https://stackoverflow.com/questions/262 ... -ms-access
however, they do not show how to do it.
QR code in report.
-
- 4StarLounger
- Posts: 415
- Joined: 04 Feb 2010, 11:46
QR code in report.
----------------------------------------------------------------------------------------
Owing at LEAST 34 beers to other helpful forum members. Especially HansV!
Owing at LEAST 34 beers to other helpful forum members. Especially HansV!
-
- Administrator
- Posts: 76649
- Joined: 16 Jan 2010, 00:14
- Status: Microsoft MVP
- Location: Wageningen, The Netherlands
Re: QR code in report.
That is for Google Maps, not for the Chart API...
I have no idea how to do what you want...
I have no idea how to do what you want...
Regards,
Hans
Hans
-
- 4StarLounger
- Posts: 415
- Joined: 04 Feb 2010, 11:46
Re: QR code in report.
no worries hans..
i found this...
https://www.tek-tips.com/viewthread.cfm?qid=1758167
which seems to declare it does what i need.. however, in practice it's just shows a blank., for the image.
still trying to debug..
steve
i found this...
https://www.tek-tips.com/viewthread.cfm?qid=1758167
which seems to declare it does what i need.. however, in practice it's just shows a blank., for the image.
still trying to debug..
steve
----------------------------------------------------------------------------------------
Owing at LEAST 34 beers to other helpful forum members. Especially HansV!
Owing at LEAST 34 beers to other helpful forum members. Especially HansV!
-
- Administrator
- Posts: 76649
- Joined: 16 Jan 2010, 00:14
- Status: Microsoft MVP
- Location: Wageningen, The Netherlands
-
- 3StarLounger
- Posts: 392
- Joined: 27 Jun 2021, 10:46
Re: QR code in report.
So, what your question boils down to is "how do I display the output of the web browser control in an Access report?"
And sadly, the answer to this is that Access can't do this
There may be a workaround. I'll experiment ...
And sadly, the answer to this is that Access can't do this
There may be a workaround. I'll experiment ...
-
- 3StarLounger
- Posts: 392
- Joined: 27 Jun 2021, 10:46
Re: QR code in report.
>seems to declare it does what i need.. however, in practice it's just shows a blank
That's because OleLoadPicturePath requires a path or URL to a file. The Google Charts REST API for a QR code does not result in such a path, thus the call quite unsurprisingly fails.
The core approach, however, is still valid and is what I am investigating
That's because OleLoadPicturePath requires a path or URL to a file. The Google Charts REST API for a QR code does not result in such a path, thus the call quite unsurprisingly fails.
The core approach, however, is still valid and is what I am investigating
-
- 3StarLounger
- Posts: 392
- Joined: 27 Jun 2021, 10:46
Re: QR code in report.
Right, this is a bare bones example, all code goes in a Module
Code: Select all
Option Compare Database
Option Explicit
' Requires an ActiveX control with a Picture property on the report
' This exampole was using an ActiveX Image control called Image1
Private Sub Report_Load()
Dim Query As String
Dim myXMLHTTP As Object
' REST API query for Google Charts QR code
Query = "https://chart.googleapis.com/chart?cht=qr&chs=200x200&chl=test"
Set myXMLHTTP = CreateObject("MSXML2.XMLHTTP")
With myXMLHTTP
.Open "GET", Query, False
.send
With CreateObject("ADODB.Stream") ' or use more classical file handling code to write a binary file with contents of myXMLHTTP.responseBody
.Type = 1 'adTypeBinary
.Open
.write myXMLHTTP.responseBody
.SaveToFile "d:\downloads\pictures\google.png", 2 ' use a filename of your own choice here
.Close
End With
Set Image1.Picture = NewLoadPicture("d:\downloads\pictures\google.png")
End With
End Sub
' Standard loadpicture doesn't understang png, but Windows Image Acquisition library does
Public Function NewLoadPicture(strPath As String) As StdPicture
With CreateObject("WIA.ImageFile")
.LoadFile (strPath)
Set NewLoadPicture = .FileData.Picture
End With
End Function
-
- 3StarLounger
- Posts: 392
- Joined: 27 Jun 2021, 10:46
Re: QR code in report.
Actually, put that together in a hurry; here's a version that does not require writing a temporary file to disk (and also means we can drop the NewLoadPicture function):
Code: Select all
' Reqwuires an ActiveX control with a Picture property on the form
' This exampole was using an ActiveX Image control called Image1
Private Sub Report_Load()
Dim Query As String
Dim myXMLHTTP As Object
Query = "https://chart.googleapis.com/chart?cht=qr&chs=200x200&chl=test"
Set myXMLHTTP = CreateObject("MSXML2.XMLHTTP")
With myXMLHTTP
.Open "GET", Query, False
.send
With CreateObject("wia.vector")
.BinaryData = myXMLHTTP.responseBody
Set Image1.Picture = .Picture
End With
End With
End Sub
-
- 3StarLounger
- Posts: 308
- Joined: 24 Dec 2015, 16:41
Re: QR code in report.
just to sanity check that the obvious has not been overlooked:
if a web browser control works in a form but not in an Access report
can we not insert a form object into a report object?
...rather that inserting the control itself directly into the report object...
if a web browser control works in a form but not in an Access report
can we not insert a form object into a report object?
...rather that inserting the control itself directly into the report object...
-
- Administrator
- Posts: 76649
- Joined: 16 Jan 2010, 00:14
- Status: Microsoft MVP
- Location: Wageningen, The Netherlands
-
- 4StarLounger
- Posts: 415
- Joined: 04 Feb 2010, 11:46
Re: QR code in report.
Thanks all.. i will give a try soon :)
----------------------------------------------------------------------------------------
Owing at LEAST 34 beers to other helpful forum members. Especially HansV!
Owing at LEAST 34 beers to other helpful forum members. Especially HansV!