Jun 23 2021 08:27 AM
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
Jun 23 2021 08:45 AM
Does your userform contain a label named LabelPicture ?
Jun 23 2021 08:47 AM
Jun 23 2021 08:57 AM
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.
Jun 23 2021 09:10 AM
Jun 23 2021 09:13 AM
@Hans Vogelaar do you mean like this?
Jun 23 2021 12:46 PM
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.