P
PeteCresswell
When users open an MS Access report via a "Reports" screen, I'm
offering up an "Excel" option where Report_Open invokes
TransferSpreadsheet against it's .RecordSource instead of creating an
MS Access report.
Works like a champ - as long as .RecordSource is a query or table
name.
Dies a horrible death if .RecordSource is some SQL concocted on-the-
fly by Report_Open.
All as expected per Dirk Goldgar's observation that
TransferSpreadsheet only works with table/query names.
In trying to craft a workaround, I wrote a routine that creates a
spreadsheet and boogies through a .Recordset, writing columns/rows.
Before creating said recordset, I do something like
1220 With fHome
1221 mySQL = Replace(mySQL, "[forms]![frmHome]![txtAsOfDate]",
"#" & !txtAsOfDate & "#")
1229 End With
to get rid of the form references.
But that doesn't deal with recordsets where query A invokes query B
and query B has ref's a form field.
So, bottom line, I'm wondering if there's some magic that will let VBA
resolve those troublesome Form.Field references. IMHO the inability
to do so seems to border on being a bug....
Or do I need to revisit my practice of embedding Form.Field references
in queries? Right now, although I don't have an alternative on the
tip of my tongue for all cases, it seems like it might be one of those
"Bad Practice" things.
offering up an "Excel" option where Report_Open invokes
TransferSpreadsheet against it's .RecordSource instead of creating an
MS Access report.
Works like a champ - as long as .RecordSource is a query or table
name.
Dies a horrible death if .RecordSource is some SQL concocted on-the-
fly by Report_Open.
All as expected per Dirk Goldgar's observation that
TransferSpreadsheet only works with table/query names.
In trying to craft a workaround, I wrote a routine that creates a
spreadsheet and boogies through a .Recordset, writing columns/rows.
Before creating said recordset, I do something like
1220 With fHome
1221 mySQL = Replace(mySQL, "[forms]![frmHome]![txtAsOfDate]",
"#" & !txtAsOfDate & "#")
1229 End With
to get rid of the form references.
But that doesn't deal with recordsets where query A invokes query B
and query B has ref's a form field.
So, bottom line, I'm wondering if there's some magic that will let VBA
resolve those troublesome Form.Field references. IMHO the inability
to do so seems to border on being a bug....
Or do I need to revisit my practice of embedding Form.Field references
in queries? Right now, although I don't have an alternative on the
tip of my tongue for all cases, it seems like it might be one of those
"Bad Practice" things.