hello sir, m using 4 combo boxes,2 option buttons,button. wen option named single type is clicked data grid must show the data i selected in combo boxes,wen all type option button is clicked then grid shows the all rows in access table.but both option buttons shows all rows in grid the code i have used is
[CODE=vb]Dim rsname1 as recordset
Dim conn As Connection
Set conn = New Connection
conn.Open "provider=Micro soft.jet.OLEdb. 4.0;Data Source=C:\Docum ents and Settings\admin\ My Documents\medic al.mdb"
Set rsname1 = New Recordset
rsname1.Open "select * from MASTER order by [PRODUCT NAME]", conn, adOpenDynamic, adLockPessimist ic
If Option2.Value = True Then
rsname1.Close
Set rsname = Nothing
rsname1.CursorL ocation = adUseClient
rsname1.Open "select * from MASTER order by [COMPANY NAME],[PRODUCT NAME],[PRODUCT TYPE],[PRODUCT SIZE]"
Form3.DataGrid1 .DataMember = ""
Set Form3.DataGrid1 .DataSource = rsname1
Form3.DataGrid1 .Refresh
rsname1.Requery
ElseIf option1.Value = True Then
rsname1.Close
Set rsname1 = Nothing
rsname1.CursorL ocation = adUseClient
rsname1.Open "select * from MASTER where [COMPANY NAME]='" & Combo1.Text & "' and [PRODUCT NAME]='" & Combo2.Text & "' and [PRODUCT TYPE]='" & Combo3.Text & "' and [PRODUCT SIZE]='" & Combo4.Text & "', conn, adOpenDynamic, adLockPessimist ic"
Form3.DataGrid1 .DataMember = ""
Set Form3.DataGrid1 .DataSource = rsname1
Form3.DataGrid1 .Refresh
rsname1.Requery
End If
End Sub[/CODE]
till now u might understood the problem m facing.actually problem is with option 2 ie single type.after clicking the command button values must appear in grid.
the error msg m getting is object r variable not decalred.please help me sir
thank u
[CODE=vb]Dim rsname1 as recordset
Dim conn As Connection
Set conn = New Connection
conn.Open "provider=Micro soft.jet.OLEdb. 4.0;Data Source=C:\Docum ents and Settings\admin\ My Documents\medic al.mdb"
Set rsname1 = New Recordset
rsname1.Open "select * from MASTER order by [PRODUCT NAME]", conn, adOpenDynamic, adLockPessimist ic
If Option2.Value = True Then
rsname1.Close
Set rsname = Nothing
rsname1.CursorL ocation = adUseClient
rsname1.Open "select * from MASTER order by [COMPANY NAME],[PRODUCT NAME],[PRODUCT TYPE],[PRODUCT SIZE]"
Form3.DataGrid1 .DataMember = ""
Set Form3.DataGrid1 .DataSource = rsname1
Form3.DataGrid1 .Refresh
rsname1.Requery
ElseIf option1.Value = True Then
rsname1.Close
Set rsname1 = Nothing
rsname1.CursorL ocation = adUseClient
rsname1.Open "select * from MASTER where [COMPANY NAME]='" & Combo1.Text & "' and [PRODUCT NAME]='" & Combo2.Text & "' and [PRODUCT TYPE]='" & Combo3.Text & "' and [PRODUCT SIZE]='" & Combo4.Text & "', conn, adOpenDynamic, adLockPessimist ic"
Form3.DataGrid1 .DataMember = ""
Set Form3.DataGrid1 .DataSource = rsname1
Form3.DataGrid1 .Refresh
rsname1.Requery
End If
End Sub[/CODE]
till now u might understood the problem m facing.actually problem is with option 2 ie single type.after clicking the command button values must appear in grid.
the error msg m getting is object r variable not decalred.please help me sir
thank u
Comment