variables

  • Thread starter Thread starter Alex Hammerstein
  • Start date Start date
A

Alex Hammerstein

Hi, In a form, I use an option choice (1 or 2) to set parameters for a
report. If the option is a 1, then we use a start date, and if a 2, we use
an end date.

The report either displays records with either the start date or end date
( both fields are displayed on the report.

I could create two reports, but if it were possible to identify to the
report which choice has been selected on the form, I could then hide the
approriate field on open report, and I could use the single report for both.

Is it possible to bring over the option value from the form to the report?

Hope this makes sense

Alex
 
Alex said:
Hi, In a form, I use an option choice (1 or 2) to set parameters for a
report. If the option is a 1, then we use a start date, and if a 2, we use
an end date.

The report either displays records with either the start date or end date
( both fields are displayed on the report.

I could create two reports, but if it were possible to identify to the
report which choice has been selected on the form, I could then hide the
approriate field on open report, and I could use the single report for both.

Is it possible to bring over the option value from the form to the report?


Yes, it is possible for a report to check for a vlaule on a
form. However, if you are just filtering the report's data,
there is no need for the report to be aware of it.

Us the form's open report button's Click event with code
like:

Dim strDoc As String
Dim strWhere As String
strDoc = "report name"
If Me.optiongroup = 1 Then
strWhere = "StartDate=" _
& Format(datetextbox,"\#m\/d\/yyyy\#")
Else
strWhere = "EndDate=" _
& Format(datetextbox,"\#m\/d\/yyyy\#")
End If

OTOH, if you are just hiding a column in the report, you
would use code in the report's Open event:

If Forms![name of form].optiongroup = 1 Then
Me.txtStartDate.Visible = False
Else
Me.txtEndDate.Visible = False
End If
 
Hi Marsh - thanks for your post and help
To test, In the OnOpen event for the report I have added:

If Forms![frmReport MembershipDates].DateType = 1 Then
MsgBox "1"
'Me.txtStartDate.Visible = False
Else
'Me.txtEndDate.Visible = False
MsgBox "2"
End If

FrmReport MembershipDates is the form, and DateType is tghe option group
name on the form.

WShen i run I get an error message that the rfeport cannot find the form
frmReport MemberfshipDates

Alex


Marshall Barton said:
Alex said:
Hi, In a form, I use an option choice (1 or 2) to set parameters for a
report. If the option is a 1, then we use a start date, and if a 2, we use
an end date.

The report either displays records with either the start date or end date
( both fields are displayed on the report.

I could create two reports, but if it were possible to identify to the
report which choice has been selected on the form, I could then hide the
approriate field on open report, and I could use the single report for
both.

Is it possible to bring over the option value from the form to the report?


Yes, it is possible for a report to check for a vlaule on a
form. However, if you are just filtering the report's data,
there is no need for the report to be aware of it.

Us the form's open report button's Click event with code
like:

Dim strDoc As String
Dim strWhere As String
strDoc = "report name"
If Me.optiongroup = 1 Then
strWhere = "StartDate=" _
& Format(datetextbox,"\#m\/d\/yyyy\#")
Else
strWhere = "EndDate=" _
& Format(datetextbox,"\#m\/d\/yyyy\#")
End If

OTOH, if you are just hiding a column in the report, you
would use code in the report's Open event:

If Forms![name of form].optiongroup = 1 Then
Me.txtStartDate.Visible = False
Else
Me.txtEndDate.Visible = False
End If
 
That error message indicates the form was not open or that
you misspelled the name of the form must

I assumed that you were using a button on the form to open
the report so the form would be open and the desired option
had been selected.

Another possibility is that your button's Click event
procedure is also closing the form. This can not be done
until after the form is report is closed.
--
Marsh
MVP [MS Access]


Alex said:
To test, In the OnOpen event for the report I have added:

If Forms![frmReport MembershipDates].DateType = 1 Then
MsgBox "1"
'Me.txtStartDate.Visible = False
Else
'Me.txtEndDate.Visible = False
MsgBox "2"
End If

FrmReport MembershipDates is the form, and DateType is tghe option group
name on the form.

WShen i run I get an error message that the rfeport cannot find the form
frmReport MemberfshipDates

Alex said:
Hi, In a form, I use an option choice (1 or 2) to set parameters for a
report. If the option is a 1, then we use a start date, and if a 2, we use
an end date.

The report either displays records with either the start date or end date
( both fields are displayed on the report.

I could create two reports, but if it were possible to identify to the
report which choice has been selected on the form, I could then hide the
approriate field on open report, and I could use the single report for
both.

Is it possible to bring over the option value from the form to the report?

"Marshall Barton" wrote
Yes, it is possible for a report to check for a vlaule on a
form. However, if you are just filtering the report's data,
there is no need for the report to be aware of it.

Us the form's open report button's Click event with code
like:

Dim strDoc As String
Dim strWhere As String
strDoc = "report name"
If Me.optiongroup = 1 Then
strWhere = "StartDate=" _
& Format(datetextbox,"\#m\/d\/yyyy\#")
Else
strWhere = "EndDate=" _
& Format(datetextbox,"\#m\/d\/yyyy\#")
End If

OTOH, if you are just hiding a column in the report, you
would use code in the report's Open event:

If Forms![name of form].optiongroup = 1 Then
Me.txtStartDate.Visible = False
Else
Me.txtEndDate.Visible = False
End If
 
Back
Top