Re: Passing info to a report from a form



On Mon, 18 Dec 2006 10:58:02 -0800, Paul Kraemer wrote:

Hi Fred,

Thanks for your response.

I actually want to pass six different strings to be displayed in my report.
Do you know if I can pass an array into OpenArgs? If so, how do I reference
the individual elements of the array on my report?

Thanks again,
Paul

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 when opening the report use the vertical
line character as text separator:

DoCmd.OpenReport "Report Name", acViewPreview, , , ,
"Hello|GoodBy|Mary|Lamb"
===========

Code the Declarations section of the report:

Option Explicit
Dim strA As String
Dim strB As String
Dim strC As String
Dim strD As String
===========
Code the Open event of the report

If Not IsNull(Me.OpenArgs) Then
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
MsgBox strA & " " & strB & vbNewLine & strC & " " & strD

End If

Note: if you intend to use the strings elsewhere in your report,
instead of declaring the strings in the open event, do it in the
declarations section so that the strings will be available every where
in the report.
--
Fred
Please respond only to this newsgroup.
I do not reply to personal e-mail
.



Relevant Pages

  • Re: [Fwd: Re: [PATCH 4/5]PCI: x86 MMCONFIG: introduce pcibios_fix_bus_scan()]
    ... >> Introduces the x86 arch-specific routine that will determine whether ... these strings defined and other strings embedded in the routine body. ... remove the string that advises posting a report. ...
    (Linux-Kernel)
  • Re: Stopping report
    ... I can send a string through OpenArgs ... these two values to do some calculations in the report. ... unbound controls in another unbound control on the forms and pass it to the ... > In its Click event you need to build two strings: ...
    (microsoft.public.access.forms)
  • Re: Refering to a Reports underlying data using VBA in Detail OnFormat event
    ... I am stuffing strings into ... Have just enough room on the report to get 30 ... have to put 4 dozen invisible check boxes on the report just to make this ...
    (microsoft.public.access.reports)
  • RE: Generate a field value, then extract from it...
    ... InStr function: ... Then on your report, you can concatenate the strings to print them: ... > There are 10 check boxes to select pizza toppings. ...
    (microsoft.public.access.forms)
  • Re: Passing info to a report from a form
    ... Do you know if that includes the Split function? ... I actually want to pass six different strings to be displayed in my report. ... Dim Var As Variant ...
    (microsoft.public.access.reports)