kelley80209
Programmer
Hi All,
I am using VB6, CR8, and AccessXP.
I access the 'Main Report' in code and pass in the SQL statement (see VB code below). I have a 'Sub Report' that is linked to the 'Main Report' through an ID field (patient_id).
The SQL for the DataSource for the 'Main Report':
SELECT patient_id, last_name, first_name FROM Patient
The SQL for the DataSource (set in CR) for the 'Sub Report':
SELECT patient_id, cath_date FROM Cath
I get the following error when I run the report: "Unable to access first record". I have run the report without the 'Sub Report' and it runs fine. I have run the 'Sub Report' query against the database and it also works fine. I am just not sure how I am supposed to link the patient_id from the 'Main Report' to the 'Sub Query' (other than 'Sub Report Link' and selecting the patient_id from the 'Main Report'.
Any help would be greatly appreciated...
TIA,
Kelley
VB Code:
Public Sub showTransRPT(ByRef pConn As ADODB.connection)
' ------------------------------------
' MAIN REPORT INFORMATION
' ------------------------------------
Dim sql As String
sql = _
"SELECT patient_id, last_name, first_name " & _
"FROM Patient "
' Perform query
Dim rsTx As ADODB.Recordset
Set rsTx = New ADODB.Recordset
rsTx.Open sql, pConn
' Set the main report data source
Dim rptTx As crPatTransplant
Set rptTx = New crPatTransplant
rptTx.Database.SetDataSource rsTx
' Now, show the report
frmRPT.showRPT rptTx
Set rptTx = Nothing
End Sub
I am using VB6, CR8, and AccessXP.
I access the 'Main Report' in code and pass in the SQL statement (see VB code below). I have a 'Sub Report' that is linked to the 'Main Report' through an ID field (patient_id).
The SQL for the DataSource for the 'Main Report':
SELECT patient_id, last_name, first_name FROM Patient
The SQL for the DataSource (set in CR) for the 'Sub Report':
SELECT patient_id, cath_date FROM Cath
I get the following error when I run the report: "Unable to access first record". I have run the report without the 'Sub Report' and it runs fine. I have run the 'Sub Report' query against the database and it also works fine. I am just not sure how I am supposed to link the patient_id from the 'Main Report' to the 'Sub Query' (other than 'Sub Report Link' and selecting the patient_id from the 'Main Report'.
Any help would be greatly appreciated...
TIA,
Kelley
VB Code:
Public Sub showTransRPT(ByRef pConn As ADODB.connection)
' ------------------------------------
' MAIN REPORT INFORMATION
' ------------------------------------
Dim sql As String
sql = _
"SELECT patient_id, last_name, first_name " & _
"FROM Patient "
' Perform query
Dim rsTx As ADODB.Recordset
Set rsTx = New ADODB.Recordset
rsTx.Open sql, pConn
' Set the main report data source
Dim rptTx As crPatTransplant
Set rptTx = New crPatTransplant
rptTx.Database.SetDataSource rsTx
' Now, show the report
frmRPT.showRPT rptTx
Set rptTx = Nothing
End Sub