Can't Reference Variable in Report (1 Viewer)

ggj13557

Registered User.
Local time
Today, 14:08
Joined
May 10, 2004
Messages
11
I am trying to reference a variable that was created within a form and use it as the title of a report. I have tried to make the variable public but still don't know enough to be able to make the report read the variable.

I have attached a small database that provides an example of what I am trying to do. In the example database you open form1, make your selection (either color or number) and it opens report1 displaying only the information that you requested. However, the submit button also contains the variable "stRptTitle" which I want to appear as the Title for the report. This title needs to change based on the information selected in form1. Here is the code as it currently stands.

___________________________________________________
Dim stLinkCriteria As String
Dim stRptTitle As String

If Frame0.Value = 1 Then
stLinkCriteria = "(((Table1.Type)='color'))"
stRptTitle = "This Is The Color Report"
End If

If Frame0.Value = 2 Then
stLinkCriteria = "(((Table1.Type)='number'))"
stRptTitle = "This Is The Number Report"
End If

DoCmd.OpenReport "Report1", acViewPreview, , stLinkCriteria

DoCmd.Close acForm, "Form1"
____________________________________________________

Any help with this problem would be greatly appreciated.
 

Attachments

  • VariableTest.zip
    17.4 KB · Views: 108

Rickster57

Registered User.
Local time
Today, 11:08
Joined
Nov 7, 2005
Messages
431
Report title

Hopefully the attached file helps. At least, I think it's attached. Put a text box on your form and set it to equal the information behind the submit button. Then refer to that field in your report.
 

ggj13557

Registered User.
Local time
Today, 14:08
Joined
May 10, 2004
Messages
11
Rickster57,

I don't see an attached file.
 

Rickster57

Registered User.
Local time
Today, 11:08
Joined
Nov 7, 2005
Messages
431
report title

Let's try it one more time
 

Attachments

  • Varaiable.zip
    18.4 KB · Views: 185

Users who are viewing this thread

Top Bottom