I have two tables in my database, one customer and other cddetails.. n i`m trying to search both tables for letter entered by user.. The code for Customer table works fine...but the code for cddetails is giving me some problem... I would appreciate if some could help me out...
Here is the code
Code for searching CD Details Table
Private Sub cmdSearch_Click()
'write a code validity
On Error GoTo errlable
again:
mpbar.Value = 0
If (cmb_mfield.Text = "Movie Category") Then
fnd = "select Cdid,MCat,MName,MRating,Rate,Cast from CdDetails where MCat like '" & Trim(txt_mvalue.Text) & "%'"
mpbar.Value = 40
ElseIf (cmb_mfield.Text = "Movie Name") Then
fnd = "select Cdid,MCat,MName,MRating,Rate,Cast from CdDetails where MName like '" & Trim(txt_mvalue.Text) & "%'"
mpbar.Value = 40
Else
fnd = "select Cdid,MCat,MName,MRating,Rate,Cast from CDDetails where " & Trim(cmb_bfield) & " like '" & Trim(txt_bvalue) & "%'"
bpbar.Value = 30
End If
If (mflag = False) Then
MR.Open fnd, conn, adOpenStatic, adLockOptimistic
mpbar.Value = 65
mdatagrid.Visible = True
Set mdatagrid.DataSource = MR
mpbar.Value = 80
mdatagrid.ReBind
mflag = True
Else
mflag = False
MR.Close
GoTo again
End If
mpbar.Value = 100
mpbar.Value = 0
Exit Sub
errlable:
mpbar.Value = 0
MsgBox Err.Number & " " & Err.Description
End Sub
Code for searching Customer Table
Private Sub cmd_bsearch_Click()
On eror GoTo errlable:
'write code for validity
again:
bpbar.Value = 0
'If (cmb_bfield.Text = " ") Then
'MsgBox ("Idiot")
If (cmb_bfield.Text = "Customer Name") Then
fnd = "select CustId,CName,CAdd,CTel,CMob from Customer where CName like'" & Trim(txt_bvalue.Text) & "%'"
bpbar.Value = 30
ElseIf (cmb_bfield.Text = "Address") Then
fnd = "select CustId,CName,CAdd,CTel,CMob from Customer where CAdd like'" & Trim(txt_bvalue.Text) & "%'"
'bpbar.Value = 30
'ElseIf (cmb_bfield.Text = "Movie Name") Then
'fnd = "select Cdid,MCat,MName,MRating,Rate,Cast from CDDetails where MName like'" & Trim(txt_bvalue.Text) & "%'"
Else
fnd = "CustId,CName,CAdd,CTel,CMob from Customer where " & Trim(cmb_bfield) & " like '" & Trim(txt_bvalue) & "%'"
bpbar.Value = 30
End If
If (bflag = False) Then
BR.Open fnd, conn, adOpenStatic, adLockOptimistic
bpbar.Value = 50
bdatagrid.Visible = True
Set bdatagrid.DataSource = BR
bpbar.Value = 70
bdatagrid.ReBind
bflag = True
bpbar.Value = 85
Else
bflag = False
BR.Close
GoTo again
bpbar.Value = 90
End If
bpbar.Value = 100
bpbar.Value = 0
Exit Sub
errlable:
bpbar.Value = 0
MsgBox Err.Description
End Sub
Both Search boxes are inside Tabs...