Mencari Rekord Dengan InputBox
Tabel yang dipakai adl Tabel Supervisor
Function CariSVisor() ' adl Fungsi Pencarian data
On Error GoTo Handl
Dim RsSVisorView As New ADODB.Recordset
Dim MySQL, NOIS, UserMsg, TXt As String
UserMsg = InputBox("Masukkan NIK Yang Dicari!", " Lab~Q 5", NOIS, 5000, 3500)
If StrPtr(UserMsg) <> 0 Then ' Start of Usermessage
NOIS = UserMsg
MySQL = "SELECT From Tab_Karyawan " & _
"WHERE NIK LIKE '%" & UserMsg & "%' And Tab_Karyawan.Jabatan Not Like 'Teknisi' And Tab_Karyawan.Jabatan Not Like 'Petugas' ORDER BY Tab_Karyawan.Nama"
RsSVisorView.Open MySQL, DbAcax, adOpenKeyset, adLockOptimistic
If RsSVisorView.BOF = True And RsSVisorView.EOF = True Then ' cari NAMA
Set RsSVisorView = Nothing
MySQL = "SELECT * From Tab_Karyawan " & _
"WHERE Nama LIKE '%" & UserMsg & "%' And Tab_Karyawan.Jabatan Not Like 'Teknisi' And Tab_Karyawan.Jabatan Not Like 'Petugas' " & _
"ORDER BY Tab_Karyawan.Nama"
RsSVisorView.Open MySQL, DbAcax, adOpenKeyset, adLockOptimistic
TxtNik.Text = RsSVisorView!NIK
TxtNama.Text = RsSVisorView!Nama
TxtAlaMat.Text = RsSVisorView!Alamat
TxtBag.Text = RsSVisorView!Bagian
TxtJbTn.Text = RsSVisorView!Jabatan
Set DGrid.DataSource = RsSVisorView ' Tampilkan Ke Datagrid
ElseIf RsSVisorView.BOF = False And RsSVisorView.EOF = False Then ' cari NIK
TxtNik.Text = RsSVisorView!NIK
TxtNama.Text = RsSVisorView!Nama
TxtAlaMat.Text = RsSVisorView!Alamat
TxtBag.Text = RsSVisorView!Bagian
TxtJbTn.Text = RsSVisorView!Jabatan
Set DGrid.DataSource = RsSVisorView ' Tampilkan Ke Datagrid
End If
Set RsSVisorView = Nothing
TxtNik.SetFocus
ElseIf StrPtr(UserMsg) = 0 Then
BukaRS
LOKED
End If ' End of Usermessage
Exit Function
Handl:
If Err = 3021 Then
MsgBox "Pencarian Data " & NOIS & " Tidak Ketemu", vbOKOnly, " Lab~Q 5"
Cari ' Loop >> Proses Pencarian
End If
End Function
Function CariSVisor() ' adl Fungsi Pencarian data
On Error GoTo Handl
Dim RsSVisorView As New ADODB.Recordset
Dim MySQL, NOIS, UserMsg, TXt As String
UserMsg = InputBox("Masukkan NIK Yang Dicari!", " Lab~Q 5", NOIS, 5000, 3500)
If StrPtr(UserMsg) <> 0 Then ' Start of Usermessage
NOIS = UserMsg
MySQL = "SELECT From Tab_Karyawan " & _
"WHERE NIK LIKE '%" & UserMsg & "%' And Tab_Karyawan.Jabatan Not Like 'Teknisi' And Tab_Karyawan.Jabatan Not Like 'Petugas' ORDER BY Tab_Karyawan.Nama"
RsSVisorView.Open MySQL, DbAcax, adOpenKeyset, adLockOptimistic
If RsSVisorView.BOF = True And RsSVisorView.EOF = True Then ' cari NAMA
Set RsSVisorView = Nothing
MySQL = "SELECT * From Tab_Karyawan " & _
"WHERE Nama LIKE '%" & UserMsg & "%' And Tab_Karyawan.Jabatan Not Like 'Teknisi' And Tab_Karyawan.Jabatan Not Like 'Petugas' " & _
"ORDER BY Tab_Karyawan.Nama"
RsSVisorView.Open MySQL, DbAcax, adOpenKeyset, adLockOptimistic
TxtNik.Text = RsSVisorView!NIK
TxtNama.Text = RsSVisorView!Nama
TxtAlaMat.Text = RsSVisorView!Alamat
TxtBag.Text = RsSVisorView!Bagian
TxtJbTn.Text = RsSVisorView!Jabatan
Set DGrid.DataSource = RsSVisorView ' Tampilkan Ke Datagrid
ElseIf RsSVisorView.BOF = False And RsSVisorView.EOF = False Then ' cari NIK
TxtNik.Text = RsSVisorView!NIK
TxtNama.Text = RsSVisorView!Nama
TxtAlaMat.Text = RsSVisorView!Alamat
TxtBag.Text = RsSVisorView!Bagian
TxtJbTn.Text = RsSVisorView!Jabatan
Set DGrid.DataSource = RsSVisorView ' Tampilkan Ke Datagrid
End If
Set RsSVisorView = Nothing
TxtNik.SetFocus
ElseIf StrPtr(UserMsg) = 0 Then
BukaRS
LOKED
End If ' End of Usermessage
Exit Function
Handl:
If Err = 3021 Then
MsgBox "Pencarian Data " & NOIS & " Tidak Ketemu", vbOKOnly, " Lab~Q 5"
Cari ' Loop >> Proses Pencarian
End If
End Function
Komentar
Posting Komentar