Buat Form Pencarian Diatas Menggunakan Visual Basic 6.0 saya akan share kepada kalian semua. Kode Script Programnya sebagai berikut:
Private Sub Cari(kodeabarang)_Click()
If Option1.Value = True ThenData1.RecordSource = "SELECT * FROM BARANG WHERE KODE_BRG = '" & Text1 & "'"
Data1.Refresh
If Data1.Recordset.EOF Then
MsgBox "Data Barang belum ada" + Chr(13) + "Coba kode yang lain", vbCritical, "Informasi"
Data1.RecordSource = ""
Text1.SetFocus
End If
ElseIf Option2.Value = True Then
Data1.RecordSource = "SELECT * FROM PELANGGAN WHERE KODE_PLG = '" & Text1 & "'"
Data1.Refresh
If Data1.Recordset.EOF Then
MsgBox "Data Pelanggan belum ada" + Chr(13) + "Coba kode yang lain", vbCritical, "Informasi"
Data1.RecordSource = ""
Text1.SetFocus
End If
Else: Option3.Value = True
Data1.RecordSource = "SELECT * FROM Supplier WHERE KODE_SUP = '" & Text1 & "'"
Data1.Refresh
If Data1.Recordset.EOF Then
MsgBox "Data Supplier belum ada" + Chr(13) + "Coba kode yang lain", vbCritical, "Informasi"
Data1.RecordSource = ""
Text1.SetFocus
End If
End If
End Sub
Private Sub Cari(nama barang)_Click()
If Option1.Value = True Then
Data1.RecordSource = "SELECT * FROM BARANG WHERE NAMA_BRG = '" & Text2 & "'"
Data1.Refresh
If Data1.Recordset.EOF Then
MsgBox "Data Barang belum ada" + Chr(13) + "Coba kode yang lain", vbCritical, "Informasi"
Data1.RecordSource = ""
Text1.SetFocus
End If
ElseIf Option2.Value = True Then
Data1.RecordSource = "SELECT * FROM PELANGGAN WHERE NAMA_PLG = '" & Text2 & "'"
Data1.Refresh
If Data1.Recordset.EOF Then
MsgBox "Data Pelanggan belum ada" + Chr(13) + "Coba kode yang lain", vbCritical, "Informasi"
Data1.RecordSource = ""
Text1.SetFocus
End If
Else: Option3.Value = True
Data1.RecordSource = "SELECT * FROM Supplier WHERE NAMA_SUP = '" & Text2 & "'"
Data1.Refresh
If Data1.Recordset.EOF Then
MsgBox "Data Supplier belum ada" + Chr(13) + "Coba kode yang lain", vbCritical, "Informasi"
Data1.RecordSource = ""
Text1.SetFocus
End If
End If
End Sub
Private Sub TampilSemua_Click()
If Option1.Value = True Then
Data1.RecordSource = "SELECT * FROM BARANG"
Data1.Refresh
ElseIf Option2.Value = True Then
Data1.RecordSource = "SELECT * FROM PELANGGAN"
Data1.Refresh
Else: Option3.Value = True
Data1.RecordSource = "SELECT * FROM SUPPLIER"
Data1.Refresh
End If
End Sub
Private Sub Command4_Click()
Unload Me
End Sub
Private Sub DBGrid1_Click()
End Sub
Private Sub Form_Load() ----- Pemanggilan database -------
Data1.DatabaseName = App.Path & "\victory.MDB"
End Sub
Private Sub Option1_Click()
Text1.Text = ""
Text2.Text = ""
End Sub
Private Sub Option2_Click()
Text1.Text = ""
Text2.Text = ""
End Sub
Private Sub Option3_Click()
Text1.Text = ""
Text2.Text = ""
End Sub
Private Sub Option4_Click()
Text2.Enabled = False
Command2.Enabled = False
Text1.Enabled = True
Text1.SetFocus
Command1.Enabled = True
Text1.Text = ""
Text2.Text = ""
End Sub
Private Sub Option5_Click()
Text2.Enabled = True
Command2.Enabled = True
Text1.Enabled = False
Text2.SetFocus
Command1.Enabled = False
Text1.Text = ""
Text2.Text = ""
End Sub
Private Sub text1_KeyPress(KeyAscii As Integer)
KeyAscii = Asc(UCase(Chr(KeyAscii)))
If KeyAscii = 13 Then
If Text1 = "" Then
Text1.SetFocus
Else
Command1.SetFocus
End If
End If
End Sub
Private Sub text2_KeyPress(KeyAscii As Integer)
KeyAscii = Asc(UCase(Chr(KeyAscii)))
If KeyAscii = 13 Then
If Text2 = "" Then
Text2.SetFocus
Else
Command2.SetFocus
End If
End If
End Sub
















