J
judith
I am trying to loop through the records of a query, for each record i want
individual reports saving to word. Somone kindly gave me some base code but
I dont really understand it.
Private Sub Command1_Click()
Dim dbs As Database
Dim rst As DAO.Recordset
Dim qdf As DAO.QueryDef
Dim BaseSQL As String
Set dbs = CurrentDb
Set qdf = dbs.QueryDefs("mailingReportBase")
Set rst = qdf.OpenRecordset()
BaseSQL = qdf.SQL
Do Until rst.EOF
qdf.SQL = Left(BaseSQL, Len(BaseSQL) - 3) & " WHERE
[companyId] =" & rst![companyId]
DoCmd.OutputTo acReport, DLookup("[name]", "templates", _
"[templeId]=" & [Forms]![systemForm]![mailContractForm].[Form]!
[letterFormBase].[Form]![template]), _
"RichTextFormat(*.rtf)", "C:\Documents and
Settings\Judith\Desktop\test1\'" & "!trial" & "'.rtf", False
Loop
rst.Close
Set rst = Nothing
qdf.SQL = BaseSQL
Set qdf = Nothing
Set dbs = Nothing
Specifically the staement Set rst = qdf.OpenRecordset()
causes an error TOO FEW PARAMETERS
and I do not understand this bit at all
qdf.SQL = Left(BaseSQL, Len(BaseSQL) - 3) & " WHERE [companyId] =" &
rst![companyId]
Any suggestions please
individual reports saving to word. Somone kindly gave me some base code but
I dont really understand it.
Private Sub Command1_Click()
Dim dbs As Database
Dim rst As DAO.Recordset
Dim qdf As DAO.QueryDef
Dim BaseSQL As String
Set dbs = CurrentDb
Set qdf = dbs.QueryDefs("mailingReportBase")
Set rst = qdf.OpenRecordset()
BaseSQL = qdf.SQL
Do Until rst.EOF
qdf.SQL = Left(BaseSQL, Len(BaseSQL) - 3) & " WHERE
[companyId] =" & rst![companyId]
DoCmd.OutputTo acReport, DLookup("[name]", "templates", _
"[templeId]=" & [Forms]![systemForm]![mailContractForm].[Form]!
[letterFormBase].[Form]![template]), _
"RichTextFormat(*.rtf)", "C:\Documents and
Settings\Judith\Desktop\test1\'" & "!trial" & "'.rtf", False
Loop
rst.Close
Set rst = Nothing
qdf.SQL = BaseSQL
Set qdf = Nothing
Set dbs = Nothing
Specifically the staement Set rst = qdf.OpenRecordset()
causes an error TOO FEW PARAMETERS
and I do not understand this bit at all
qdf.SQL = Left(BaseSQL, Len(BaseSQL) - 3) & " WHERE [companyId] =" &
rst![companyId]
Any suggestions please