Solved Custom Ribbon images type mismatch error

bodders24

New member
Local time
Today, 04:31
Joined
Oct 3, 2016
Messages
24
I have created an accdb (Access 365 64-bit) for Holiday planning and budgeting, and it has a couple of ribbons with some custom images. To make the application more self-contained I have created a table USysRibbonImages to store them within the database itself. This has 3 fields – ControlID (text), Images (Attachment), and Description (Test). I have loaded the png image files into this table, and used this function on startup:

Code:
    Dim strPath             As String
    Dim rstParent           As DAO.Recordset
    Dim rstChild            As DAO.Recordset2
    Dim fldData             As DAO.Field2
    Dim fldName             As DAO.Field2
    Dim fld                 As Scripting.Folder
    
    strPath = CurrentProject.Path & "\temp"
    
    Set rstParent = CurrentDb.OpenRecordset("USysRibbonImages")
    Do Until rstParent("Controlid") = strBtnName
        rstParent.MoveNext
    Loop
    Set rstChild = rstParent.Fields("Images").Value
    Set fldData = rstChild.Fields("FileData")
    Set fldName = rstChild.Fields("FileName")
    
'   Check if the temporary folder temp exists. If not, creates it and put
'   in hidden mode.
    Set mfso = New FileSystemObject
    If mfso.FolderExists(strPath) = False Then
        Set fld = mfso.CreateFolder(strPath)
        fld.Attributes = fld.Attributes + 2
    End If
    
    fldData.SaveToFile (strPath)
    '
    Set fldName = Nothing
    Set fldData = Nothing
    Set rstChild = Nothing
    Set rstParent = Nothing
    
'   The function gives the name and the path of the saved file, that will
'   be given the function LoadImage
    ExtractImage = strPath & "\" & strImageName

Until recently it was all working well, but - without changing any code - I am now getting a Type Mismatch error on this line.

Set fldData = rstChild.Fields("FileData")

The type is 11 - Binary data (bitmap)

Does anybody have any thoughts or suggestions ? Any help much appreciated

Bodders
 
That was a quick response and a successful one. Changing Field2 to Field did the trick.

Many thanks for that

Bodders
 
That was a quick response and a successful one. Changing Field2 to Field did the trick.

Many thanks for that

Bodders
Congratulations! Glad to hear you got it sorted out. Good luck with your project.
 

Users who are viewing this thread

Back
Top Bottom