UtterAccess.com
X   Site Message
(Message will auto close in 2 seconds)

Welcome to UtterAccess! Please ( Login   or   Register )

Custom Search
 
   Reply to this topicStart new topic
> Order By Sort With Report, Access 2010    
 
   
ronehrlich
post Sep 7 2019, 02:09 PM
Post#1



Posts: 49
Joined: 18-April 09



We are trying to use VBA to sort a report during an open, but having no luck. Please help. Here is the VBA statement:
docmd.openreport "name of report",acviewpreview,,,"orderby [mymonth] ASC"
When we run this we get the type mismatch error.
Any suggestions would be extremely appreciated.
Go to the top of the page
 
projecttoday
post Sep 7 2019, 02:38 PM
Post#2


UtterAccess VIP
Posts: 11,067
Joined: 10-February 04
From: South Charleston, WV


The fifth argument of .openreport is Window Mode. Did you mean the sixth argument (Openargs)? in which case you need another comma.

--------------------
Robert Crouser
Go to the top of the page
 
RJD
post Sep 7 2019, 03:27 PM
Post#3


UtterAccess VIP
Posts: 10,087
Joined: 25-October 10
From: Gulf South USA


Hi: In addition to adding the additional comma, as Robert indicated, I would also remove the "orderby" from the OpenArgs and just use "[mymonth] ASC" ... although the ASC is the default and not necessary.

Then in the OnOpen event procedure of the report, use ...

CODE
Private Sub Report_Open(Cancel As Integer)
Me.OrderBy = Me.OpenArgs
Me.OrderByOn = True
End Sub

I would also suggest that you consider using a form control to enter/select the OpenArgs and reference that in the DoCmd.OpenReport command. That way you will not have to dig into the event procedure to change the OpenArgs parameter.

HTH
Joe

--------------------
"Each problem that I solved became a rule, which served afterwards to solve other problems."
"You just keep pushing. You just keep pushing. I made every mistake that could be made. But I just kept pushing."

Rene Descartes 1596-1650 (Mathematician and Philosopher)
Go to the top of the page
 
arnelgp
post Sep 8 2019, 12:46 AM
Post#4



Posts: 1,467
Joined: 2-April 09
From: somewhere out there...


you may do it like this in VBA:
CODE
Docmd.OpenReport "name of report",acViewPreview
Reports("name of report").OrderBy="[mymonth] ASC"
Reports("name of report").OrderByOn=True


--------------------
Never stop learning, because life never stops teaching.
Go to the top of the page
 
BruceM
post Sep 9 2019, 06:47 AM
Post#5


UtterAccess VIP
Posts: 7,968
Joined: 24-May 10
From: Downeast Maine


Do you want the users to be able to specify the sort order? If not, why not just use the report's built-in Order By tool?
Go to the top of the page
 


Custom Search


RSSSearch   Top   Lo-Fi    18th October 2019 - 09:18 AM