Sending Peramiter Values to a Variable

G

Guest

Hi,
I have a report that is based on a query. The query is filled with
information between two dates that are set as peramiters in the query. [Start
Date] and [End Date]. How do I pass the values of the peramiters to my
variables to undertake a calculation to show how many days there are between
the dates. My code is as follows and in the OnActivate event of my report:

Private Sub Report_Activate()
Dim StartDate As Integer
Dim EndDate As Integer
Dim Days As Integer
Dim query As Control
StartDate = [Start Date] '[Start Date] and [End Date] are peramiters
EndDate = [End Date] 'that are taken from a query to produce the
report
Days = EndDate - StartDate
Me.txtDays = Days 'txtDays is the control I wish to pass the
calculation to
End Sub
 
M

Marshall Barton

Jurrasicway said:
I have a report that is based on a query. The query is filled with
information between two dates that are set as peramiters in the query. [Start
Date] and [End Date]. How do I pass the values of the peramiters to my
variables to undertake a calculation to show how many days there are between
the dates. My code is as follows and in the OnActivate event of my report:

Private Sub Report_Activate()
Dim StartDate As Integer
Dim EndDate As Integer
Dim Days As Integer
Dim query As Control
StartDate = [Start Date] '[Start Date] and [End Date] are peramiters
EndDate = [End Date] 'that are taken from a query to produce the
report
Days = EndDate - StartDate
Me.txtDays = Days 'txtDays is the control I wish to pass the
calculation to
End Sub


That code looks like it would work, but only if you have a
text box that refers to the parameters. However, since you
seem to want to put the calculations in a text box anyway,
there is no need to use any code to do it. Just set a text
box's expression to something like:
=DateDiff("d", [Start Date], [End Date])
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top