dbTalk Databases Forums  

Report's recordsource

comp.databases.ms-access comp.databases.ms-access


Discuss Report's recordsource in the comp.databases.ms-access forum.



Reply
 
Thread Tools Display Modes
  #1  
Old   
Phil
 
Posts: n/a

Default Report's recordsource - 10-08-2010 , 04:55 AM






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

Reply With Quote
  #2  
Old   
Salad
 
Posts: n/a

Default Re: Report's recordsource - 10-08-2010 , 11:18 AM






Phil wrote:

Quote:
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.

Reply With Quote
  #3  
Old   
Phil
 
Posts: n/a

Default Re: Report's recordsource - 10-08-2010 , 02:38 PM



On 08/10/2010 17:18:05, Salad wrote:
Quote:
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.



Thanks Salad - solved it

Call MergeAllWord(CurrentDb.QueryDefs(Rpt.RecordSource) .SQL)

Can't open AcDesign as the Db ends up as an AccDE

Phil

Reply With Quote
  #4  
Old   
kate suomah
 
Posts: n/a

Default hello - 10-09-2010 , 08:33 AM



Hello Dear
I saw your email in your profile here( www.eggheadcafe.com ) and become interested; my name is;Kate please send me your email address (kategur90 (AT) yahoo (DOT) in) to my box now so that i can send you my picture then we will know each other more;
Thanks Kate
kategur90 (AT) yahoo (DOT) in

Submitted via EggHeadCafe - Software Developer Portal of Choice
SharePoint Create List Add/Edit Form Web Part With Custom Toolbar and Attachments Option
http://www.eggheadcafe.com/tutorials...ts-option.aspx

Reply With Quote
Reply




Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off



Powered by vBulletin Version 3.5.3
Copyright ©2000 - 2012, Jelsoft Enterprises Ltd.