OpenArgs

  • Thread starter Thread starter James Frater
  • Start date Start date
J

James Frater

Hello Everyone,

Is it possible to pass two different strings to two different text boxes on
a report through OpenArgs?

Example: I'm trying to pass the string strReportHeader to the text box
txtReportHeader and the string strPagetHeader to the text box txtPageHeader
in the report rptCompliance.

At the moment I have this on a OnClick event of a button on a form. My code
is currently:

Private Sub btnCompliance_Click()
Dim strWhere As String
Dim strReportHeader As String
Dim strPageHeader As String
Call LoadWY

strWhere = "startweek=" & W & " AND " & "startyear=" & Y
strReportHeader = "Compliance for Week " & W & " " & Y & ""
strPageHeader = **the wording for this is still being worked on**

DoCmd.OpenReport "rptCompliance", acViewPreview, , strWhere, ,
OpenArgs:=??????
Reports("rptCompliance").Caption = strReportHeader

As always many thanks

JAMES F
 
hi James,

James said:
Is it possible to pass two different strings to two different text boxes on
a report through OpenArgs? Yes.

DoCmd.OpenReport "rptCompliance", acViewPreview, , strWhere, ,
OpenArgs:=arguments
With

arguments = strReportHeader & "|" & strPageHeader

Assuming that you don't use the pipe as content, otherwise you should
choose another delimiter or handle it correctly.

In the report load event:

Dim arguments () As String

If Len(Trim(Nz(Me.OpenArgs, ""))) > 0 Then
arguments = Split(Me.OpenArgs, "|")
MsgBox arguments(0) & " - " & arguments(1)
End If


mfG
--> stefan <--
 
Morning Stefan,

Thanks for your quick response.

The strings are carrying through perfectly (also a colleague is thoroughly
enjoying the msgbox) however I can't get the two strings to seperate out into
the different text boxes on the report.

I have the control source of the text boxes set to =Report.OpenArgs, I'm
guessing that's causing the issue, but for the life of me I can't work out
what I'm doing wrong.

Many thanks

JAMES
 
hi James,

James said:
I have the control source of the text boxes set to =Report.OpenArgs, I'm
guessing that's causing the issue, but for the life of me I can't work out
what I'm doing wrong.
You need to set the values in VBA, e.g.:
lblReportHeader.Caption = arguments(0)
lblPageHeader.Caption = arguments(1)

mfG
--> stefan <--
 
Stefan,

I think I'm having one of those mornings! I was trying to set the values of
the text box not the Label!

All works perfectly now, thank you.

JAMES
 
Back
Top