I am coding a project that connects to database, ‘chdata’ at run time. The database has two tables named ‘FamRec’ and ‘IndRec’. These tables have associated with two ADO Data Controls ‘adoFamily’ and ‘adoIndividual’. One-to-Many Relationship exits between the two tables. The FamNo joins the two tables; FamRec table is the primary table; IndRec is the secondary table. I want VB code that will enable me to display related records in the secondary table as I move through the records of the primary table. I try to select all fields from IndRec table where ‘FamNo’ field in IndRec equals ‘FamNo’ in FamRec with the SQL select statement shown below. But when I run the project it generates the above error statement. Any help will be greatly appreciated.
Dim CS As String
Dim SQLQ As String
Dim SQLQFAM As String
CS = "Provider=Microsoft.Jet.OLEDB.4.0;Persist Security Info=False;" & _
"Data Source=" & App.Path & "\chdata.mdb"
adoFamily.ConnectionString = CS
SQLQFAM = "SELECT * FROM FAMREC"
adoFamily.RecordSource = SQLQFAM
adoFamily.Refresh
adoIndividual.ConnectionString = CS
SQLQ = "SELECT * FROM INDREC WHERE INDREC.FAMNO=FAMREC.FAMNO"
adoIndividual.RecordSource = SQLQ
adoIndividual.Refresh
Dim CS As String
Dim SQLQ As String
Dim SQLQFAM As String
CS = "Provider=Microsoft.Jet.OLEDB.4.0;Persist Security Info=False;" & _
"Data Source=" & App.Path & "\chdata.mdb"
adoFamily.ConnectionString = CS
SQLQFAM = "SELECT * FROM FAMREC"
adoFamily.RecordSource = SQLQFAM
adoFamily.Refresh
adoIndividual.ConnectionString = CS
SQLQ = "SELECT * FROM INDREC WHERE INDREC.FAMNO=FAMREC.FAMNO"
adoIndividual.RecordSource = SQLQ
adoIndividual.Refresh