Kamis, 30 Agustus 2012

Form Untuk Mengakses Image


TOMBOL BROWSE
Private Sub cmdbrowse_Click()
CD.ShowOpen
Image1.Picture = LoadPicture(CD.FileName)
XFOTO = CD.FileName
txtfoto.Text = XFOTO
End Sub


TOMBOL SIMPAN


Private Sub cmdsimpan_Click()
If txtkodeuser.Text = "" Then Exit Sub
adouser.Recordset.MoveFirst
adouser.Recordset.Find "[KodeUser]= '" & txtkodeuser.Text & "' "
If adouser.Recordset.EOF Then
    adouser.Recordset.AddNew
End If
    adouser.Recordset!kodeuser = txtkodeuser.Text
    adouser.Recordset!namauser = Trim(txtnamauser.Text)
    adouser.Recordset!jabatan = Trim(txtjabatan.Text)
    adouser.Recordset!Password = Trim(txtpassword.Text)
    adouser.Recordset!foto = Trim(txtfoto.Text)
adouser.Recordset.Update
adouser.Refresh
kosongkan
Call MsgBox("Data Telah Tersimpan", vbInformation, "Simpan Data")
End Sub

TAMPILKAN DATA


Private Sub txtkodeuser_Change1()
If txtkodeuser.Text <> "" Then
    adouser.Recordset.Filter = "KodeUser Like '*" & txtkodeuser.Text & "*' "
    If Not (adouser.Recordset.EOF Or adouser.Recordset.BOF) Then
        txtnamauser.Text = adouser.Recordset!namauser
        txtjabatan.Text = adouser.Recordset!jabatan
        txtpassword.Text = adouser.Recordset!Password
                On Error GoTo pesan
                If Not IsNull(adouser.Recordset!foto) Then
                txtfoto.Text = adouser.Recordset!foto
               Image1.Picture = LoadPicture(adouser.Recordset!foto)
                End If
                Exit Sub
pesan: MsgBox ("Maaf, path anda salah Jadi fotonya tidak tampil")

        
        Exit Sub
    Else
        adouser.Refresh
txtnamauser.Text = ""
txtjabatan.Text = ""
txtpassword.Text = ""
txtfoto.Text = ""
Image1.Picture = Nothing
        
        Exit Sub
    End If
Else
adouser.Refresh
kosongkan
Exit Sub
End If
End Sub


Tidak ada komentar:

Posting Komentar

hay friend... sebelum exit, jgn lupa tinggalkan comment dulu ya...
kalau mau bertanya bisa tulis komentar atau email/fb ke: aranama@ymail.com
thank you...