Compile error: Method or data member not found

%3CLINGO-SUB%20id%3D%22lingo-sub-2475906%22%20slang%3D%22en-US%22%3ECompile%20error%3A%20Method%20or%20data%20member%20not%20found%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-2475906%22%20slang%3D%22en-US%22%3E%3CP%3Ehi%3C%2FP%3E%3CP%3Ei%20have%20problem%20with%20my%20VBA%20code.%20Here%20my%20codes%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EDim%20ErwinG%20As%20String%3CBR%20%2F%3EPrivate%20Sub%20CMP_UPLOAD_Click()%3CBR%20%2F%3EOn%20Error%20GoTo%20Salah%3CBR%20%2F%3EDim%20Erwin%20As%20Integer%3CBR%20%2F%3EIf%20Me.TXTNAMA.Value%20%3D%20%22%22%20Then%3CBR%20%2F%3ECall%20MsgBox(%22Isi%20terlebih%20dahulu%20pada%20Nama%20Dokter%22%2C%20vbInformation%2C%20%22Nama%20Dokter%22)%3CBR%20%2F%3EExit%20Sub%3CBR%20%2F%3EEnd%20If%3CBR%20%2F%3EApplication.FileDialog(msoFileDialogOpen).AllowMultiSelect%20%3D%20False%3CBR%20%2F%3EErwin%20%3D%20Application.FileDialog(msoFileDialogOpen).Show%3CBR%20%2F%3EIf%20Erwin%20%26lt%3B%26gt%3B%200%20Then%3CBR%20%2F%3EErwinG%20%3D%20Application.FileDialog(msoFileDialogOpen).SelectedItems(1)%3CBR%20%2F%3EMe.Image1.Picture%20%3D%20LoadPicture(ErwinG)%3CBR%20%2F%3EMe.Image1.PictureSizeMode%20%3D%201%3CBR%20%2F%3EMe.LabelPicture.Caption%20%3D%20ThisWorkbook.Path%20%26amp%3B%20%22%5C%22%20%26amp%3B%20Me.TXTNAMA.Value%20%26amp%3B%20%22.jpg%22%3CBR%20%2F%3EEnd%20If%3CBR%20%2F%3EExit%20Sub%3CBR%20%2F%3ESalah%3A%3CBR%20%2F%3ECall%20MsgBox(%22Tipe%20file%20tidak%20mendukung%20untuk%20ditampilkan%2C%20pastikan%20pilih%20file%20dengan%20tipe%20*.Jpg*%2C%20atau%20*.Jpeg*%22%2C%20vbInformation%2C%20%22Simpan%20Gambar%22)%3C%2FP%3E%3CP%3EEnd%20Sub%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3Eit%20says%20%22Compile%20error%3A%20Method%20or%20data%20member%20not%20found%22%20when%20i%20click%20on%20%22FOTO%22%20button.%20if%20this%20code%20success%20it%20will%20be%20open%20the%20explorer%20and%20choose%20any%20photo's%20and%20then%20save%20it.%3CBR%20%2F%3Eactually%2C%20this%20is%20youtube%20tutorial%20code.%20i%20did%20the%20same%20way%20as%20the%20video%20said.%20i've%20tried%20to%20ask%20the%20author%20but%20i%20dont%20get%20the%20answer.%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3Ehere%20the%20link%20that%20video%20i%20mean%26nbsp%3B%3CBR%20%2F%3E%3CA%20href%3D%22https%3A%2F%2Fwww.youtube.com%2Fwatch%3Fv%3DycY_6o_DODo%26amp%3Blc%3DUgwRMyBAPNVOibqhbXR4AaABAg.9LxPENArfzx9OwJCi6DXvM%22%20target%3D%22_blank%22%20rel%3D%22noopener%20nofollow%20noreferrer%22%3Ehttps%3A%2F%2Fwww.youtube.com%2Fwatch%3Fv%3DycY_6o_DODo%26amp%3Blc%3DUgwRMyBAPNVOibqhbXR4AaABAg.9LxPENArfzx9OwJCi6DXvM%3C%2FA%3E%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-LABS%20id%3D%22lingo-labs-2475906%22%20slang%3D%22en-US%22%3E%3CLINGO-LABEL%3EMacros%20and%20VBA%3C%2FLINGO-LABEL%3E%3C%2FLINGO-LABS%3E%3CLINGO-SUB%20id%3D%22lingo-sub-2476051%22%20slang%3D%22en-US%22%3ERe%3A%20Compile%20error%3A%20Method%20or%20data%20member%20not%20found%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-2476051%22%20slang%3D%22en-US%22%3E%3CP%3E%3CA%20href%3D%22https%3A%2F%2Ftechcommunity.microsoft.com%2Ft5%2Fuser%2Fviewprofilepage%2Fuser-id%2F1086194%22%20target%3D%22_blank%22%3E%40oslowow%3C%2FA%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3EDoes%20your%20userform%20contain%20a%20label%20named%20LabelPicture%20%3F%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-2476052%22%20slang%3D%22en-US%22%3ERe%3A%20Compile%20error%3A%20Method%20or%20data%20member%20not%20found%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-2476052%22%20slang%3D%22en-US%22%3Ei%20thought%20is%20not..%20where%20should%20i%20put%20that%20%22LabelPicture%22%3F%3C%2FLINGO-BODY%3E
New Contributor

hi

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
Salah:
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 
https://www.youtube.com/watch?v=ycY_6o_DODo&lc=UgwRMyBAPNVOibqhbXR4AaABAg.9LxPENArfzx9OwJCi6DXvM

6 Replies

@oslowow 

Does your userform contain a label named LabelPicture ?

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

@oslowow 

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?

@oslowow

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.

 

S0532.png