String Data Type mismatch

mjdemaris

Working on it...
Local time
Today, 07:17
Joined
Jul 9, 2015
Messages
426
So I am using a file dialog to select a picture and display it for an item in our inventory.

Code:
Private Sub cmdBrowse_Click()

    Dim strFile As String
    Dim strName As String

    strFile = ShowDialog
    
    strName = strFile
    
Debug.Print strName
    
    strName = Right(strFile, 10)
    strName = Left(strName, 6)
    
Debug.Print strName
    Me.imgPic.Picture = strFile
    
End Sub

This code comes from a test form, which works fine.

However, when i use this exact code in my production form, i get a type mismatch @
Code:
strName = Left(strName, 6)
.

I've tried dimming the variables as variant, but that did not work either.

I've also deleted the code, removed the blank lines, compiled and reinserted the code.

Not sure what to check next.
 
strName contains six characters: in this test i chose a png file named P00445.png, so strName would contain P00445.

I just found out that if the form is tied to the record source, i get this error, but if no record source, then it works fine.

Also, no objects are bound to the record source, just the form.

Well, I suspect it has something to do with the query:
-two tables, where both ID fields are equal. Setting this to "select all from the left and only those from right which are equal" works on the test form, however, not the production form.

The production form opens via a macro fired from an click event, where ID = ID_FK.

I may need to do something else on how this form opens, or ...perhaps a DAO option or ... maybe a lookup function.
 
Last edited:

Users who are viewing this thread

Back
Top Bottom