Compile error: Method or data member not found

New Contributor


i have problem with my VBA code. Here my codes


Dim ErwinG As String
Private Sub CMP_UPLOAD_Click()
On Error GoTo Salah
Dim Erwin As Integer
If Me.TXTNAMA.Value = "" Then
Call MsgBox("Isi terlebih dahulu pada Nama Dokter", vbInformation, "Nama Dokter")
Exit Sub
End If
Application.FileDialog(msoFileDialogOpen).AllowMultiSelect = False
Erwin = Application.FileDialog(msoFileDialogOpen).Show
If Erwin <> 0 Then
ErwinG = Application.FileDialog(msoFileDialogOpen).SelectedItems(1)
Me.Image1.Picture = LoadPicture(ErwinG)
Me.Image1.PictureSizeMode = 1
Me.LabelPicture.Caption = ThisWorkbook.Path & "\" & Me.TXTNAMA.Value & ".jpg"
End If
Exit Sub
Call MsgBox("Tipe file tidak mendukung untuk ditampilkan, pastikan pilih file dengan tipe *.Jpg*, atau *.Jpeg*", vbInformation, "Simpan Gambar")

End Sub


it says "Compile error: Method or data member not found" when i click on "FOTO" button. if this code success it will be open the explorer and choose any photo's and then save it.
actually, this is youtube tutorial code. i did the same way as the video said. i've tried to ask the author but i dont get the answer.


here the link that video i mean

6 Replies


Does your userform contain a label named LabelPicture ?

i thought is not.. where should i put that "LabelPicture"?


You can place it anywhere on the userform.

Alternatively, if you don't need the label, remove the line


Me.LabelPicture.Caption = ThisWorkbook.Path & "\" & Me.TXTNAMA.Value & ".jpg"


from the code. You won't get the error.


ok then. i'll try. thank you so much

@Hans Vogelaar do you mean like this?


No, either place a label control on the userform (not in the code) and name it LabelPicture, or remove the line that mentions LabelPicture from the code.