berikut ini tampilan form pencarian data

untuk script kodenya neeeh...
'form utama
Private Sub Command1_Click()
On Error Resume Next
Dim cari As String
Dim cari1 As String
Dim cari2 As String
cari = "nama='" & Text1.Text & "'"
cari1 = "alamat='%" & Text1.Text & "'%"
cari2 = "notelp='%" & Text1.Text & "'%"
Adodc1.Recordset.MoveFirst
Adodc1.Recordset.Find cari
Adodc1.Recordset.Find cari1
Adodc1.Recordset.Find cari2
'Adodc1.Recordset.EOF
If Combo1.ListIndex = 0 Then
Adodc1.Recordset.MoveFirst
Adodc1.Recordset.Find cari
Form2.Show
detail
ElseIf Combo1.ListIndex = 1 Then
Adodc1.Recordset.MoveFirst
Adodc1.Recordset.Find cari1
Form2.Show
detail
ElseIf Combo1.ListIndex = 5 Then
Adodc1.Recordset.MoveFirst
Adodc1.Recordset.Find cari2
Form2.Show
detail
End If
Adodc1.Recordset.MoveFirst
End Sub
Sub detail()
'On Error Resume Next
Dim MGrs As String
MGrs = String$(50, "-")
Form2.CurrentX = 0
Form2.CurrentY = 0
Form2.Font = "Courier New"
Form2.FontSize = 10
Form2.FontBold = True
Form2.Print Tab(27); ""
Form2.Print Tab(5); " D E T A I L P E N C A R I A N D A T A "
Form2.FontBold = False
Form2.Print
Form2.Print Tab(5); "Nama : ";
Form2.Print Tab(15); Adodc1.Recordset!nama
Form2.Print Tab(5); "Alamat : ";
Form2.Print Tab(15); Adodc1.Recordset!alamat
Form2.Print Tab(5); "No Telp : ";
Form2.Print Tab(15); Adodc1.Recordset!notelp
Form9.FontBold = False
Form9.Print Tab(5); ""
Form9.Print Tab(5); ""
Form9.Print Tab(5); ""
End Sub
Private Sub Form_Load()
End Sub
Private Sub Text1_KeyPress(KeyAscii As Integer)
KeyAscii = Asc(UCase(Chr(KeyAscii)))
If KeyAscii = 13 Then
If Combo1.ListIndex = 0 Then
Adodc1.RecordSource = "select * from data where nama like'%" & Text1.Text & "%'"
Adodc1.Refresh
ElseIf Combo1.ListIndex = 1 Then
Adodc1.RecordSource = "select * from data where alamat like'%" & Text1.Text & "%'"
Adodc1.Refresh
ElseIf Combo1.ListIndex = 2 Then
Adodc1.RecordSource = "select * from data where notelp like'%" & Text1.Text & "%'"
Adodc1.Refresh
End If
End If
End Sub
Private Sub Text1_KeyUp(KeyCode As Integer, Shift As Integer)
Select Case KeyCode
Case Is = vbKeyEscape
Adodc1.RecordSource = "select * from data"
Adodc1.Refresh
End Select
End Sub
Nah, mudah khan?? tinggal bagaimana vbthok mania mengembangkan sendiri sehingga pencarian lebih akurat.Tapi saya rasa ini sudah contoh yang paling akurat..hehehe...
untuk yang males membuatnya silakan download disini
Tidak ada komentar:
Posting Komentar