![]() | |
#1
| |||
| |||
|
#2
| |||
| |||
|
|
Snippet of code to get the recordset of a form or report If [Type] = 5 Then ' Query Call MergeAllWord(CurrentDb.QueryDefs(ObjName).SQL) ElseIf [Type] = 6 Then ' Tables Call MergeAllWord("", CurrentDb.TableDefs(ObjName).OpenRecordset) ElseIf [Type] = -32768 Then ' Forms DoCmd.OpenForm ObjName, , , , acFormReadOnly, acHidden, "Hidden" Set Frm = Forms(ObjName) Call MergeAllWord("", Frm.RecordsetClone) Set Frm = Nothing DoCmd.Close acForm, ObjName ElseIf [Type] = -32764 Then ' Reports DoCmd.OpenReport ObjName, acViewPreview, , , acHidden, "Hidden" Set Rpt = Reports(ObjName) Call MergeAllWord("", Rpt.Recordset) Set Rpt = Nothing DoCmd.Close acReport, ObjName Else MsgBox "Unknown object type - Can't do a mail merge", vbInformation End If The bit for the form works correctly, but the line Call MergeAllWord("", Rpt.Recordset) gives error 32585 "This feature is only available in an ADP" How do I get either the recordset or the SQL to pass to the MergeAllWord routine? probably being a bit thick Thanks Phil |
#3
| |||
| |||
|
|
Phil wrote: Snippet of code to get the recordset of a form or report If [Type] = 5 Then ' Query Call MergeAllWord(CurrentDb.QueryDefs(ObjName).SQL) ElseIf [Type] = 6 Then ' Tables Call MergeAllWord("", CurrentDb.TableDefs(ObjName).OpenRecordset) ElseIf [Type] = -32768 Then ' Forms DoCmd.OpenForm ObjName, , , , acFormReadOnly, acHidden, "Hidden" Set Frm = Forms(ObjName) Call MergeAllWord("", Frm.RecordsetClone) Set Frm = Nothing DoCmd.Close acForm, ObjName ElseIf [Type] = -32764 Then ' Reports DoCmd.OpenReport ObjName, acViewPreview, , , acHidden, "Hidden" Set Rpt = Reports(ObjName) Call MergeAllWord("", Rpt.Recordset) Set Rpt = Nothing DoCmd.Close acReport, ObjName Else MsgBox "Unknown object type - Can't do a mail merge", vbInformation End If The bit for the form works correctly, but the line Call MergeAllWord("", Rpt.Recordset) gives error 32585 "This feature is only available in an ADP" How do I get either the recordset or the SQL to pass to the MergeAllWord routine? probably being a bit thick Thanks Phil strSQL = Frm.RecordSource then pass the strSQL variable? You might have to determine if there is an FilterOn/OrderByOn and concatenate but I doubt since you are simply opening and closing, not operating on an already open form. Heck, why not open the form in acDesign and forget the set stuff. |
#4
| |||
| |||
|
![]() |
| Thread Tools | |
| Display Modes | |
| |