I need to get qr picture to be visible on a report(Payment invoice). (1 Viewer)

m-taha

New member
Local time
Today, 12:20
Joined
Dec 6, 2019
Messages
29
So i have this code, a function that creates a qr code from the information it gets and stores it in a file on my pc. and opens a report with a picture of the qr code on it, and to refresh it every time it's called when runnung the invoice code.

this the function:
Code:
Public Function qr_erstellen(k_name As String, d_name As String, k_plz As String, d_plz As String, k_stadt As String, d_stadt As String, k_land As String, d_land As String, k_str As String, d_str As String, k_str_nr As String, d_str_nr As String, k_betrag As Single, d_iban As String, Bericht As String) As PngByteQRCode

Dim qr As QRCoderVBA
Set qr = New QRCoderVBA

Dim k_referenz As String
Dim filename As String

filename = "QR_" & k_name & Date

qr.setCreditor k_name, k_plz, k_stadt, k_land, k_str, k_str_nr
qr.setAmount k_betrag
qr.setDebitor d_name, d_plz, d_stadt, d_land, d_str, d_str_nr
qr.setIban d_iban
qr.setReference ("")
qr.GenerateSwissQRCode ("C:\Entwicklung\Mathani\QR_PIC\" & filename & ".png")




     Dim pfad As String
  
     pfad = "C:\Entwicklung\Mathani\QR_PIC\" & filename & ".png"
  
    DoCmd.OpenReport Bericht, acPreview
  
    Reports(Bericht)!QRBild.Picture = pfad
  
    DoCmd.Close acReport, Bericht, acSaveYes
  
          
    'png löschen
     'Kill pfad
  
End Function


And this is the invoice code which exists within a Command button:
(You can clearly see where i mess things up trying to make it work)

Code:
Private Sub Bef_Rechnung_drucken_Click()

On Error GoTo Err_Bef_Rechnung_drucken_Click

 


    'Datensatz speichern

     DoCmd.DoMenuItem acFormBar, acRecordsMenu, acSaveRecord, , acMenuVer70

 

   


    DoCmd.OpenQuery "qryStundenrapport_Bereinigung_1"

    DoCmd.OpenQuery "qryStundenrapport_Bereinigung_2"

    DoCmd.OpenQuery "qryStundenrapport_Bereinigung_3"

    DoCmd.OpenQuery "qryStundenrapport_Bereinigung_4"

    DoCmd.OpenQuery "qryRechnungspositionenLoeschen"

    DoCmd.OpenQuery "qryRechnungspositionenArbeitsleistungHinzufuegen"

    DoCmd.OpenQuery "qryRechnungspositionenMaterialHinzufuegen"

    DoCmd.OpenQuery "qryRechnungspositionenDrittleistungenHinzufuegen"

 




 

    Dim d_name As String

    Dim d_plz As String

    Dim d_stadt As String

    Dim d_str As String

    Dim d_str_nr As String

    Dim d_iban As String

    Dim Mandant As Integer

 

    Mandant = GetMandant()

 

    d_name = DLookup("Wert", "tblMandantEinstellungen", "Einstellung = 'firmenname'")

    d_plz = "9000"

    d_stadt = "berlin"

    d_str = "West"

    d_str_nr = "154"

    d_iban = "CH4431999123000889012"

 

 

 

   'k_name As String, d_name As String, k_plz As String, d_plz As String, k_stadt As String, d_stadt As String, k_land As String, d_land As String, k_str As String, d_str As String, k_str_nr As String, d_str_nr As String, k_betrag As Single, d_iban As String, Bericht As String


    DoCmd.DoMenuItem acFormBar, acRecordsMenu, 5, , acMenuVer70

   

 


    Call mdlQR.qr_erstellen("Dolly", d_name, "1245", d_plz, "paris", d_stadt, "CH", "SE", "kstrasse", d_str, "kstrnr", d_str_nr, "45698", "CH4431999123000889012", "berRechnung")



    Dim stDocName As String


    stDocName = "berRechnung"

   

    DoCmd.OpenReport stDocName, acPreview



 

 

 

    DoCmd.Maximize


Exit_Bef_Rechnung_drucken_Click:

    Exit Sub


Err_Bef_Rechnung_drucken_Click:

    MsgBox err.Description

    Resume Exit_Bef_Rechnung_drucken_Click

 

End Sub

and also bellow i attached 2 screenshots of report in page form and design mode.

i really appreciate any kind of help, i've been on this project for months now and it's getting really frustrating. So i really appreciate every bit help. Thank you .
 

Attachments

  • entwurfsansicht.png
    entwurfsansicht.png
    109 KB · Views: 157
  • Seitenansicht.png
    Seitenansicht.png
    70.9 KB · Views: 237

theDBguy

I’m here to help
Staff member
Local time
Today, 04:20
Joined
Oct 29, 2018
Messages
21,474
Hi. If you have an image of the QR code saved to your hard drive, then you should be able to just use a Picture/Image control and point it to the image location (I think).
 

m-taha

New member
Local time
Today, 12:20
Joined
Dec 6, 2019
Messages
29
Hi. If you have an image of the QR code saved to your hard drive, then you should be able to just use a Picture/Image control and point it to the image location (I think).

thank you for replying, i could do that , but i want it to be placed there automatically, cause it would be a waste of time and impractical for the people who are going to use it (they generate the invoice when filling an access form and clicking the print invoice button) .
 

theDBguy

I’m here to help
Staff member
Local time
Today, 04:20
Joined
Oct 29, 2018
Messages
21,474
thank you for replying, i could do that , but i want it to be placed there automatically, cause it would be a waste of time and impractical for the people who are going to use it (they generate the invoice when filling an access form and clicking the print invoice button) .
Hmm, not sure what you mean. I was referring to placing the picture control on the report at design time, so when the report is viewed or printed, whatever qr code applies to the report just show up automatically.
 

m-taha

New member
Local time
Today, 12:20
Joined
Dec 6, 2019
Messages
29
Hmm, not sure what you mean. I was referring to placing the picture control on the report at design time, so when the report is viewed or printed, whatever qr code applies to the report just show up automatically.

hmm.. i'm not sure either what i meant now 😅 but i already have an image control placed (QRBild) on the report, but it just shows up blank every time i run the code (i get no errors) just the picture doesn't show up at all
 

theDBguy

I’m here to help
Staff member
Local time
Today, 04:20
Joined
Oct 29, 2018
Messages
21,474
hmm.. i'm not sure either what i meant now 😅 but i already have an image control placed (QRBild) on the report, but it just shows up blank every time i run the code (i get no errors) just the picture doesn't show up at all
Well, in my mind, no code is necessary to display the qr code. You may use the code to generate the qr code image, but displaying it on the report, shouldn't need any code at all (or maybe just a minimal amount of code).
 

m-taha

New member
Local time
Today, 12:20
Joined
Dec 6, 2019
Messages
29
Well, in my mind, no code is necessary to display the qr code. You may use the code to generate the qr code image, but displaying it on the report, shouldn't need any code at all (or maybe just a minimal amount of code).

i know, right!? there isn't much written anyways it worked at one attempt when i happened to place the order of code line differently but now it doesn't work, i'm literally just putting it randomly to make it happen again (which is stupid i know)

1-i thought of placing it somewhere before the line that previews the report for printing.
2- thought of placing a command in the QR Code generator function to open the report and place the QR pic and then close it
3- and placing the code like in 1 again.
sadly none of it worked
 

deletedT

Guest
Local time
Today, 12:20
Joined
Feb 2, 2019
Messages
1,218
It may not be the answer to your question. But it's worth knowing it.
I use BarCodeWiz. After installing this app, an activeX object is added to Access. I simply drag the acitveX control to a report and link it to a field of a table.

When I open the report, barcode is sitting there. No need to even 1 line of code.
 

arnelgp

..forever waiting... waiting for jellybean!
Local time
Today, 19:20
Joined
May 7, 2009
Messages
19,245
maybe somewhere in your code, after calling the qr generator, you then check if an image file is actually created and that its file length is not 0.
if it exists, you then assign it to Picture property of the image control.
 

isladogs

MVP / VIP
Local time
Today, 12:20
Joined
Jan 14, 2017
Messages
18,235
@Tera
I believe your post is describing one way of adding a barcode whereas this thread is concerned with QR codes
 

deletedT

Guest
Local time
Today, 12:20
Joined
Feb 2, 2019
Messages
1,218
@isladogs I've never used QRcodes. But as far as I know when I purchased BarCodeWiz, it could handle QR codes too.
Its home page still shows 2D-QR Code as one of its possibilities.
But I may have misunderstood something. Because I personally didn't used it.
 
Last edited:

isladogs

MVP / VIP
Local time
Today, 12:20
Joined
Jan 14, 2017
Messages
18,235
@Tera
No idea. I just responded to your post. I'd never heard of BarCodeWiz and you didn't supply a link.
For barcodes, I just use a barcode font Code39 which avoids having to load an ActiveX control
 

m-taha

New member
Local time
Today, 12:20
Joined
Dec 6, 2019
Messages
29
maybe somewhere in your code, after calling the qr generator, you then check if an image file is actually created and that its file length is not 0.
if it exists, you then assign it to Picture property of the image control.

i do check it every time i run the code and there's always a picture of a qr code with the correct information, i change them up every time to check that's it's working correctly

this is the bit where the code generator is supposed to open the report and add the picture to the image control and close it afterwards

Code:
DoCmd.OpenReport Bericht, acPreview
 
    Reports(Bericht)!QRBild.Picture = pfad
 
    DoCmd.Close acReport, Bericht, acSaveYes

so it should be there on the report when i open the report and preview it for printing in the second code after calling the code generator

Code:
Call mdlQR.qr_erstellen("Dolly", d_name, "1245", d_plz, "paris", d_stadt, "CH", "SE", "kstrasse", d_str, "kstrnr", d_str_nr, "45698", "CH4431999123000889012", "berRechnung")

    Dim stDocName As String

    stDocName = "berRechnung"

    DoCmd.OpenReport stDocName, acPreview

but it just doesn't

any ideas ? 😅
 

m-taha

New member
Local time
Today, 12:20
Joined
Dec 6, 2019
Messages
29
It may not be the answer to your question. But it's worth knowing it.
I use BarCodeWiz. After installing this app, an activeX object is added to Access. I simply drag the acitveX control to a report and link it to a field of a table.

When I open the report, barcode is sitting there. No need to even 1 line of code.
thank youu, bust don't think my coworker would be too thrilled to add another field table t link it from, tried once 😅 , "just save it on the pc drive and delete it later so we don't waste anymore space"
 

theDBguy

I’m here to help
Staff member
Local time
Today, 04:20
Joined
Oct 29, 2018
Messages
21,474
thank youu, bust don't think my coworker would be too thrilled to add another field table t link it from, tried once 😅 , "just save it on the pc drive and delete it later so we don't waste anymore space"
If you use the same name every time, then you can just design it into your report. Create a sample QR code with the permanent name, add an unbound Image control on your report and point it to the sample QR code. When you run the code, it will replace the image and when you open the report, it will show the new QR code.
 

Minty

AWF VIP
Local time
Today, 12:20
Joined
Jul 26, 2013
Messages
10,371
I think what everyone is saying here is that you shouldn't need to keep saving the external file to the report, simply do it once in design mode.
When the external image is updated it will automatically get updated next time you open the report.
 

bastanu

AWF VIP
Local time
Today, 04:20
Joined
Apr 13, 2010
Messages
1,402
Agree with saving the path and be done with (if you like to save the codes with different names you would need to simply set the path in the Report_Open event of the report).
I think your problem is with trying to modify the report in Print Preview mode (acPreview) instead of Design view (acDesign). Try:
DoCmd.OpenReport Bericht, acViewDesign

Cheers,
Vlad
 

The_Doc_Man

Immoderate Moderator
Staff member
Local time
Today, 06:20
Joined
Feb 28, 2001
Messages
27,191
I'm reading this thread but something isn't clicking. I'm going to ruminate for a moment on the subject. Maybe I'm off base, but...

A bound control is bound because you have a way to load its .Value from an underlying recordset - by associating it with a field, using the .ControlSource property, for example. That bound control then gets updated visually during the Form_Update event (whether or not you have code there). It works because the .Value property is the default of any bindable control (i.e. one that has a value) and if the .ControlSource points to the field, the field gets loaded to the control's .Value property - and gets displayed. Totally automatic.

An image control doesn't have a .Value at all. That fact alone means it is not bindable in the formal sense of the word. It has a .Picture property - but that .Picture property is not the default property of the image control. There is no automatic linkage that I can recall that will load a non-default control property without some sort of VBA, however short and simple. So the only reasonable way to load up an image control is to have a file-specification field in the table or query that is the form's .Recordsource (or generate it with VBA) and then during the Form_Update event, add a line of code to copy the file spec (text string) into the image's .Picture property. That's as close as I've ever seen it get to making a picture become loaded "automatically."

For reports, the same logic would be true, but don't forget that reports have different events. In print-preview mode you fire the OnPrint event, but in report-view mode you fire a different event (On Format?), because reports are built differently based on whether you are preparing to view the report on screen or print the report on paper. So for this putative report image, you would have to put code in either of those events to do the same thing - load the .Picture property.

This is where I get confused. In the code that you showed as the first post of your thread, you showed exactly this action, loading the .Picture to set the image. You are doing the right thing but I keep on coming back to the idea that you want to not even do that much. Or did I miss your goal entirely?
 

Users who are viewing this thread

Top Bottom