L
longhair
afternoon all
i'm trying to populate a report with a dao recordset. the recordset contains the proper data, but i can't seem to pass the info to select queries(3) for their parameters to run the report
any and all suggestions are welcome
Module
Option Compare Databas
Public rstEffect As DAO.Recordse
Public Part As Strin
Public Sub btnRunReport_Click(
On Error GoTo Err_btnRunReport_Clic
Dim stDocName As Strin
Dim dbs As DAO.Databas
Dim qdfEffect As DAO.QueryDe
'Dim rstEffect As DAO.Recordse
Dim param As DAO.Paramete
Dim txtDate As Dat
Dim fld As DAO.Fiel
Dim varData As Varian
Dim intCount As Intege
Dim DateField As Dat
Dim Part As Strin
Dim strSql As Strin
varData = "
intCount =
txtDate = Me.Form.ReportDat
MsgBox txtDat
Set dbs = CurrentD
Set qdfEffect = dbs.QueryDefs("ToolRoomEffectivenessQuery"
'qdfEffect.Parameters("pInitial") = "yes
qdfEffect.Parameters("pQueryDate") = txtDat
Set rstEffect = qdfEffect.OpenRecordset(dbOpenDynaset
MsgBox rstEffect.RecordCoun
Part = rstEffect.Fields("Part Number"
MsgBox Par
'stDocName = "rptTest1
stDocName = "ToolRoomEffectivenessReport
DoCmd.OpenReport stDocName, acPrevie
rstEffect.Clos
Set rstEffect = Nothin
Exit_btnRunReport_Click
Exit Su
Err_btnRunReport_Click
MsgBox Err.Descriptio
Resume Exit_btnRunReport_Clic
End Su
Private Sub Report_Open(Cancel As Integer
Dim dbs As DAO.Databas
Dim qdfEffectDetail As DAO.QueryDe
Dim rstEffectDetail As DAO.Recordse
'Dim rstEffect As DAO.Recordse
Dim paramDetail As DAO.Paramete
Dim fld As DAO.Fiel
Set dbs = CurrentD
Set qdfEffectDetail = dbs.QueryDefs("Query2"
qdfEffectDetail.Parameters("pJobNum") = rstEffect.Fields("Job Number"
qdfEffectDetail.Parameters("pParDie") = rstEffect.Fields("Parent Die"
qdfEffectDetail.Parameters("pDieType") = rstEffect.Fields("Die Type"
qdfEffectDetail.Parameters("pRows") = rstEffect.Fields("Rows"
Set rstEffectDetail = qdfEffectDetail.OpenRecordset(dbOpenDynaset
Do Until rstEffect.EO
Me.RecordSource = rstEffect.Nam
rstEffect.MoveNex
Loo
End Su
what the problem appears to be, for example,is that data in rstEffect.Fields(Job Number) is not being passed to qdfEffectDetail.Parameters("pJobNum"). i have pJobNum defined as a parameter in my sql, but when i run the code the query (Query2) still prompts me for the input parameters. we can deal with txtDate not being passed to qdfEffect.Parameters("pQueryDate") since we know the date to report on. the fact is that we do not know which records will be returned for the parent portion "ToolRoomEffectivenessQuery" so we will not know what data is needed for the child portion "Query2"
ti
regards
longhair
i'm trying to populate a report with a dao recordset. the recordset contains the proper data, but i can't seem to pass the info to select queries(3) for their parameters to run the report
any and all suggestions are welcome
Module
Option Compare Databas
Public rstEffect As DAO.Recordse
Public Part As Strin
Public Sub btnRunReport_Click(
On Error GoTo Err_btnRunReport_Clic
Dim stDocName As Strin
Dim dbs As DAO.Databas
Dim qdfEffect As DAO.QueryDe
'Dim rstEffect As DAO.Recordse
Dim param As DAO.Paramete
Dim txtDate As Dat
Dim fld As DAO.Fiel
Dim varData As Varian
Dim intCount As Intege
Dim DateField As Dat
Dim Part As Strin
Dim strSql As Strin
varData = "
intCount =
txtDate = Me.Form.ReportDat
MsgBox txtDat
Set dbs = CurrentD
Set qdfEffect = dbs.QueryDefs("ToolRoomEffectivenessQuery"
'qdfEffect.Parameters("pInitial") = "yes
qdfEffect.Parameters("pQueryDate") = txtDat
Set rstEffect = qdfEffect.OpenRecordset(dbOpenDynaset
MsgBox rstEffect.RecordCoun
Part = rstEffect.Fields("Part Number"
MsgBox Par
'stDocName = "rptTest1
stDocName = "ToolRoomEffectivenessReport
DoCmd.OpenReport stDocName, acPrevie
rstEffect.Clos
Set rstEffect = Nothin
Exit_btnRunReport_Click
Exit Su
Err_btnRunReport_Click
MsgBox Err.Descriptio
Resume Exit_btnRunReport_Clic
End Su
Private Sub Report_Open(Cancel As Integer
Dim dbs As DAO.Databas
Dim qdfEffectDetail As DAO.QueryDe
Dim rstEffectDetail As DAO.Recordse
'Dim rstEffect As DAO.Recordse
Dim paramDetail As DAO.Paramete
Dim fld As DAO.Fiel
Set dbs = CurrentD
Set qdfEffectDetail = dbs.QueryDefs("Query2"
qdfEffectDetail.Parameters("pJobNum") = rstEffect.Fields("Job Number"
qdfEffectDetail.Parameters("pParDie") = rstEffect.Fields("Parent Die"
qdfEffectDetail.Parameters("pDieType") = rstEffect.Fields("Die Type"
qdfEffectDetail.Parameters("pRows") = rstEffect.Fields("Rows"
Set rstEffectDetail = qdfEffectDetail.OpenRecordset(dbOpenDynaset
Do Until rstEffect.EO
Me.RecordSource = rstEffect.Nam
rstEffect.MoveNex
Loo
End Su
what the problem appears to be, for example,is that data in rstEffect.Fields(Job Number) is not being passed to qdfEffectDetail.Parameters("pJobNum"). i have pJobNum defined as a parameter in my sql, but when i run the code the query (Query2) still prompts me for the input parameters. we can deal with txtDate not being passed to qdfEffect.Parameters("pQueryDate") since we know the date to report on. the fact is that we do not know which records will be returned for the parent portion "ToolRoomEffectivenessQuery" so we will not know what data is needed for the child portion "Query2"
ti
regards
longhair