By the way, I set the recordsource of the report in the openreport event,
using openargs.
I am now trying to send two strings (the sql statement and the orderby
clause) but it seems I cannot send an array as opening argument.
Anybody know anything about it?
Allen Browne said:
If you need to do so, you can set the ControlSource of the GroupLevel.
Example in:
Sorting report records at runtime
at:
http://allenbrowne.com/ser-33.html
You can send many strings in the one OpenArgs argument.
Here is one method that uses the "|" character to separate the various
parts within the OpenArgs argument.
Assuming you are using a newer version of Access that includes the
Split() function.
First Copy and Paste the following Function into a Module:
Public Function ParseText(TextIn As String, x) As Variant
On Error Resume Next
Dim Var As Variant
Var = Split(TextIn, "|", -1)
ParseText = Var(x)
End Function
========
To pass the multiple OpenArgs to the report (4 of them in this
example):
DoCmd.OpenReport"ReportName", , , , , "Hello|GoodBy|Mary|Lamb"
===========
Code the Open event of that Report:
If Not IsNull(Me.OpenArgs) Then
Dim strA As String
Dim strB As String
Dim strC As String
Dim strD As String
strA = ParseText(OpenArgs, 0)
strB = ParseText(OpenArgs, 1)
strC = ParseText(OpenArgs, 2)
strD = ParseText(OpenArgs, 3)
' Then do what you want with the resulting strings
End If