C
Caitlin Anstee
Hi everyone,
I've tried everything and I just can't seem to wrap my head around
what i'm doing wrong!
This was my first attempt at getting the printed version of a form to
reflect the current sort order that as user has created:
Public Sub testPrint()
CurrentDb.QueryDefs("PrintQuery").SQL = Left((CurrentDb.QueryDefs
("PrintQuery").SQL), 187) + "ORDER BY " + orderByString
DoCmd.SelectObject acForm, "PrintView", True
'DoCmd.PrintOut
DoCmd.SelectObject acForm, "Main", False
End Sub
No luck. The printed form did not reflect sort order at all. Strange.
Okay, here's attempt number two where I open the form, explicitely
restate the recordsource, save it and close it.
Public Sub testPrint()
CurrentDb.QueryDefs("PrintQuery").SQL = Left((CurrentDb.QueryDefs
("PrintQuery").SQL), 187) + "ORDER BY " + orderByString
DoCmd.OpenForm "PrintView", acFormDS
Forms("PrintView").RecordSource = "PrintQuery"
DoCmd.Save acForm, "PrintView"
DoCmd.Close acForm, "PrintView"
DoCmd.SelectObject acForm, "PrintView", True
'DoCmd.PrintOut
DoCmd.SelectObject acForm, "Main", False
End Sub
But it still doesn't work!!!!
My query reflects the new orderby clause perfectly. If I open it in
design view it's there. If I look at the sql it is the exact string I
created, If I open the query the datasheet is exactly the way I wanted
it to be with my data sorted accordingly. At the very least I know
I've done that part right. I haven't made a syntax error or anything
simple like that.
But I cannot make this form print properly at all. It always retains
its previous sort order -- the default sort order as the inital state
of the form doesn't even have a sort order defined. It never respects
the orderby clause. It doesn't read it at all.
I need my printed form to reflect the sort order that the user has
selected which is stored in orderByString.
Has anybody encountered this before? Is it not possible for a
datasheet to reflect the contents of an orderby clause from sql?
Thanks for even reading this.
C.
I've tried everything and I just can't seem to wrap my head around
what i'm doing wrong!
This was my first attempt at getting the printed version of a form to
reflect the current sort order that as user has created:
Public Sub testPrint()
CurrentDb.QueryDefs("PrintQuery").SQL = Left((CurrentDb.QueryDefs
("PrintQuery").SQL), 187) + "ORDER BY " + orderByString
DoCmd.SelectObject acForm, "PrintView", True
'DoCmd.PrintOut
DoCmd.SelectObject acForm, "Main", False
End Sub
No luck. The printed form did not reflect sort order at all. Strange.
Okay, here's attempt number two where I open the form, explicitely
restate the recordsource, save it and close it.
Public Sub testPrint()
CurrentDb.QueryDefs("PrintQuery").SQL = Left((CurrentDb.QueryDefs
("PrintQuery").SQL), 187) + "ORDER BY " + orderByString
DoCmd.OpenForm "PrintView", acFormDS
Forms("PrintView").RecordSource = "PrintQuery"
DoCmd.Save acForm, "PrintView"
DoCmd.Close acForm, "PrintView"
DoCmd.SelectObject acForm, "PrintView", True
'DoCmd.PrintOut
DoCmd.SelectObject acForm, "Main", False
End Sub
But it still doesn't work!!!!
My query reflects the new orderby clause perfectly. If I open it in
design view it's there. If I look at the sql it is the exact string I
created, If I open the query the datasheet is exactly the way I wanted
it to be with my data sorted accordingly. At the very least I know
I've done that part right. I haven't made a syntax error or anything
simple like that.
But I cannot make this form print properly at all. It always retains
its previous sort order -- the default sort order as the inital state
of the form doesn't even have a sort order defined. It never respects
the orderby clause. It doesn't read it at all.
I need my printed form to reflect the sort order that the user has
selected which is stored in orderByString.
Has anybody encountered this before? Is it not possible for a
datasheet to reflect the contents of an orderby clause from sql?
Thanks for even reading this.
C.