Home > Back-end >  How do I implement QR code generator into a different access file?
How do I implement QR code generator into a different access file?

Time:08-18

I came accross this this post: Access Error

I am trying to implement the QR code generator into my own access program. This is the onl oad code: it's the exact same and all paths are still the same.

    Dim rsParent As DAO.Recordset2
Dim rsChild As DAO.Recordset2
Dim fld As DAO.Field2
Dim strExcel As String

strExcel = CurrentProject.Path & "\QRCode.xlsm"
If Dir(strExcel) = "" Then
    Set rsParent = CurrentDb.OpenRecordset("tblQRSheet", dbOpenDynaset)
    rsParent.MoveFirst
    Set rsChild = rsParent.Fields("attachment").Value
    Set fld = rsChild.Fields("FileData")
    fld.SaveToFile strExcel
    Set fld = Nothing
    rsChild.Close
    rsParent.Close
    Set rsChild = Nothing
    Set rsParent = Nothing
End If
If Dir(CurrentProject.Path & "\QRCodeImages", vbDirectory) = "" Then
    MkDir CurrentProject.Path & "\QRCodeImages"
End If

Set gxlApp = CreateObject("Excel.Application")
Set gxlWB = gxlApp.Workbooks.Open(CurrentProject.Path & "\QRCode.xlsm", False, False)

If anyone has any ideas or can help me make this QR code generator work in my own file that would be great. I think that it has to do with the Form's Record Source.

CodePudding user response:

That error implies that you are using types (classes) that are not defined. You have to add the references for it to work. Probably the DAO reference is missing in your project. Go to Tools->References and select "Microsoft DAO 3.6 Object Library". Also the "Microsoft Excel Object Library" might be needed, even if the sample code uses an Object to create the Excel application.

In case this works but you still cannot generate QR codes, consider using an external executable that does just that, and call it using something like:

Dim strCmd As String : strCmd = """" & CurrentDBDir() & "\qrcode.exe"" -o " & """" & myFile & """" & " -s 10 -l H " & """" & strCode & """"
ShellWait strCmd

Where ShellWait is the utility created by Terry Kreft

  • Related