This is driving me insane. I am working on a report where I need to programmatically set the OrderBy property.
Here is a snippet of the code I am using.
DoCmd.OpenReport FileString, acViewPreview, , wClause
If OrderByStr = "" Then
Application.Reports(FileString).OrderByOn = False
Application.Reports(FileString).OrderByOn = True
Application.Reports(FileString).OrderBy = OrderByStr
DoCmd.OutputTo acOutputReport, FileString, acFormatSNP, Outputdir + "\" + CStr(iRequestID) + "-" & FileString + ".snp", False
The orderby string that I am testing contains two fields, comma separated. ("wolevel_idx,wo_idx")
When I run this, it seems to only order by wo_idx. However if I uncomment the msgbox line, and let this message popup, it magically orders them correctly. What the hell is going on here. I guess it needs some time to set the order by before running the report? Is there some command I am missing to tell it wait for the previous command(setting orderby) to finish before running the next command(outputto). Is VB in access not single threaded? Why doesn't anything in access ever JUST WORK.
I'm giving this question all my remaing points, hopefully it's enough.