Hi. I am using vb6 for searching and displaying a particular record from MS-ACCESS.
I have two forms namely Search1 and Search2.
In the Search1 form, I have two combobox named degree and branch1 and one button named search.
I have retrieved the data for those two combobox from two different tables named "degree" and "dept" from MS-ACCESS database.
But the data i am going to search from another table named "subjectcode".
When I click search button, the corresponding full record of select item in two comobobox should be displayed in the Datagrid named "Grid1" that placed in the Search2.
Here is my complete code and i am getting error while I use sql query to retrieve and display those data.
Here is the code of Search1 of Form_Load
I have two forms namely Search1 and Search2.
In the Search1 form, I have two combobox named degree and branch1 and one button named search.
I have retrieved the data for those two combobox from two different tables named "degree" and "dept" from MS-ACCESS database.
But the data i am going to search from another table named "subjectcode".
When I click search button, the corresponding full record of select item in two comobobox should be displayed in the Datagrid named "Grid1" that placed in the Search2.
Here is my complete code and i am getting error while I use sql query to retrieve and display those data.
Here is the code of Search1 of Form_Load
Private Sub Form_Load() Set con = New ADODB.Connection con.Open "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=.\college.mdb;Persist Security Info=False" con.CursorLocation = adUseClient If con.State = 0 Then MsgBox "Connection Failed! Check Connection", "Error" End If Set rs = New ADODB.Recordset rs.Open "select distinct DegId from Degree", con, 1, 3 Do Until rs.EOF degree.AddItem rs.Fields(0) rs.MoveNext Loop rs.Close rs.Open "select distinct DeptName from Dept", con, 1, 3 Do Until rs.EOF branch1.AddItem rs.Fields(0) rs.MoveNext Loop rs.Close End Sub Private Sub search_Click() Set rs = New ADODB.Recordset rs.Open "select * from subjectcode where degree='" & degree, "Branch=" & branch1, con, 1, 3 Set Search2.Grid1.DataSource = rs Search2.Show Search1.Hide End Sub