Create Swiss QR-Bills in Microsoft Access with BarCodeWiz QR Code Fonts
- The Swiss QR-bill is a standardized payment format used in Switzerland. It includes a QR Code containing invoice information such as the recipient's bank account, address, payment amount, and currency.
- This tutorial demonstrates how to create a Swiss QR-bill invoice in Microsoft Access using BarCodeWiz QR Code Fonts. You will learn how to generate a QR Code containing the required information, add the Swiss Cross to its center, and include it in an invoice report.
Step 1. Import module with barcode functions
Click on Database Tools tab > Visual Basic (or press Alt + F11).
Right-click the database and Import File....
- Select BarCodeWizQrCode.bas
- The default location of the file is:
C:\Program Files\BarCodeWiz\BarCodeWiz QR Code Fonts\BarCodeWizQrCode.bas
The following module should now be part of the Access file.
Step 2. Create a new table
Create a new table with invoice data. Name the table InvoiceData (or use the InvoiceData table from our example database). Our table has the following fields and data:
Step 3. Create a new report in Design Mode
- In Microsoft Access, select the Create tab and click Report Design.
- Open the report's Property Sheet (press F4) and select the Data tab.
- Set the Record Source property to InvoiceData, the table created in Step 2.
- Save the report as rpt_Rechnung.
Step 4. Generate Swiss QR Code
- On the Report Design tab, select Text Box and place it in the payment section of the invoice within the report's Detail section.
- Select the text box and open its Property Sheet (F4). On the Data tab, locate the Control Source property.
- Enter the following expression in the Control Source property to generate the Swiss QR Code using the invoice data from the InvoiceData table.
=QrCodeEncode("SPC" & Chr(13) & Chr(10) & "0200" & Chr(13) & Chr(10) & "1" & Chr(13) & Chr(10) & Replace([IBAN]," ","")
& Chr(13) & Chr(10) & "S" & Chr(13) & Chr(10) & [SellerName] & Chr(13) & Chr(10) & [SellerAddress] & Chr(13) & Chr(10)
& [SellerBuildingNumber] & Chr(13) & Chr(10) & [SellerPostalCode] & Chr(13) & Chr(10) & [SellerCity] & Chr(13) & Chr(10)
& "CH" & Chr(13) & Chr(10) & "" & Chr(13) & Chr(10) & "" & Chr(13) & Chr(10) & "" & Chr(13) & Chr(10) & "" & Chr(13) &
Chr(10) & "" & Chr(13) & Chr(10) & "" & Chr(13) & Chr(10) & "" & Chr(13) & Chr(10)
& Replace(Format([GrossTotal],"Fixed"),",",".") & Chr(13) & Chr(10) & [Currency] & Chr(13) & Chr(10) & "S" & Chr(13)
& Chr(10) & [BuyerName] & Chr(13) & Chr(10) & [BuyerAddress] & Chr(13) & Chr(10) & [BuyerBuildingNumber]
& Chr(13) & Chr(10) & [BuyerPostalCode] & Chr(13) & Chr(10) & [BuyerCity] & Chr(13) & Chr(10) & "CH" & Chr(13)
& Chr(10) & "NON" & Chr(13) & Chr(10) & "" & Chr(13) & Chr(10) & [Reference] & Chr(13) & Chr(10)
& "EPD",1,2,False,4,0,"UTF-8")
- On the Format tab, set the Font Name to BCW_QR and the Font Size to 4. Adjust the text box dimensions to accommodate the generated QR Code. The exact QR Code dimensions will be adjusted in Step 6.
Step 5. Design the Swiss Invoice
- Add labels and text boxes for the seller's and buyer's information, invoice number, dates, and payment details.
- In Design View, arrange the invoice fields and labels to create the invoice layout.
- Add text boxes for NetTotal, VATTotal, and GrossTotal. Format the amounts to display two decimal places.
- Switch to Print Preview to check the invoice layout and make any necessary adjustments.
Step 6 — Add the Swiss Cross
- Adjust the QR Code to measure 46 × 46 mm, excluding the quiet zone.
- On the Report Design tab, select Image from the Controls menu.
- Insert an image of the Swiss Cross (a white cross on a black square) and set its dimensions to 7 × 7 mm.
- Position the Swiss Cross in the center of the QR Code. Use the Left and Top properties on the Format tab of the image's Property Sheet to adjust its position manually. The exact values depend on the report layout.
- Make sure the Swiss Cross is centered over the actual QR Code rather than the text box itself. Switch to Print Preview to check the alignment and make any necessary adjustments.