Re: Stopping report
From: albertsong (albertsong_at_discussions.microsoft.com)
Date: 10/20/04
- Next message: Ken Snell [MVP]: "Re: rounding values in Access"
- Previous message: hermie: "Re: Function as event handler"
- In reply to: Allen Browne: "Re: Stopping report"
- Next in thread: Allen Browne: "Re: Stopping report"
- Reply: Allen Browne: "Re: Stopping report"
- Messages sorted by: [ date ] [ thread ]
Date: Wed, 20 Oct 2004 14:05:02 -0700
OK, now I understand how to use the WhereCondition and how to use OpenArgs to
send strings through. In my example, I can send a string through OpenArgs
that says "between 10/1/04 07:00AM and 10/4/04 09:00AM".
But, I also need either the values themselves or the difference between
these two values to do some calculations in the report. I already have a
function JustMinutes that calculates the difference in minutes so that's not
the issue. I'm dividing the run time of a machine during the user entered
time by the total time available between the user entered time to get
utilization. As I see it, I can:
1. Pass both of the actual date/time values from the unbound controls and
calculate the difference in the report OR
2. Calculate the difference between the actual date/time values from the
unbound controls in another unbound control on the forms and pass it to the
report
Either way, how do I use OpenArgs to pass this value (to do calculations) in
addition to the string?
"Allen Browne" wrote:
> You will have a command button on your form that actually opens the report.
> In its Click event you need to build two strings: one as the WhereCondition
> for OpenReport, and the other as the description for the user.
>
> In Access 2002 and 2003, you can pass the description through the OpenArgs,
> and just add a text box on the report with Control Source of:
> =[Report].[OpenArgs]
> In earlier versions, assign strDescrip to the Caption of a hidden label on
> your form, and use the Format event of the Report Header section to read it,
> and copy to a text box on the report.
>
> This example shows how to create the 2 strings for different field types,
> using the different delimiters. Note that the date range example copes with
> the fact that the field may have a time component by asking for "less than
> the next day".
>
> Private Sub cmdPreview_Click()
> Dim strWhere As String 'Where Condition
> Dim strDescrip As String 'Description of Where Condition.
> Dim lngLen As Long 'Length of string.
> Const conJetDate ="\#mm\/dd\/yyyy\#" 'Format for dates.
>
> 'Text field example.
> If Not IsNull(Me.txtSurname) Then
> strWhere = strWhere & "([Surname] = """ & Me.txtSurname & """) AND "
> strDescrip = strDescrip & "Surname of " & Me.txtSurname & ". "
> End If
>
> 'Number field example.
> If Not IsNull(Me.txtAmount) Then
> strWhere = strWhere & "([Amount] >= " & Me.txtAmount & ") AND "
> strDescrip = strDescrip & "Amount at least " & Format(Me.txtAmount,
> "Currency") & ". "
> End If
>
> 'Date range example
> If Not IsNull(Me.txtStartDate) Then
> strWhere = strWhere & "([MyDateField] >= " & _
> Format(Me.txtStartDate, conJetDate) & ") AND "
> strDescrip = ...
> End If
> If Not IsNull(Me.txtEndDate) Then
> strWhere = strWhere & "([MyDateField] < " & _
> Format(Me.txtEndDate + 1, conJetDate) & ") AND "
> End If
>
> 'Chop of the trailing " AND "
> lngLen = Len(strWhere) - 5
> If lngLen > 0 Then
> strWhere = Left$(strWhere, lngLen)
> strDescrip = Left$(strDescrip, Len(strDescrip) - 2)
> End If
>
> 'Open the report
> DoCmd.OpenReport "MyReport", acViewPreview, , strWhere,
> OpenArgs:=strDescrip
> End Sub
>
>
> --
> Allen Browne - Microsoft MVP. Perth, Western Australia.
> Tips for Access users - http://allenbrowne.com/tips.html
> Reply to group, rather than allenbrowne at mvps dot org.
>
> "albertsong" <albertsong@discussions.microsoft.com> wrote in message
> news:6BF77DDC-35D2-404D-816B-B2E44110C435@microsoft.com...
> > Thanks for all of the help and support...just a couple more questions...
> >
> > I've created an unbound form that has unbound controls for everything that
> > a
> > user might want to filter on (like date range, machine, shift, etc.)
> >
> > How do I use the information that the user enters in the unbound controls
> > to:
> > 1. Filter the results of query for the report
> > 2. Display the user entry information on the report
> >
> > For instance, the user enters a StartDate and EndDate for records. The
> > query must limit the records to info bewteen those dates and then I need
> > to
> > display the dates the user requested on the report.
>
>
>
- Next message: Ken Snell [MVP]: "Re: rounding values in Access"
- Previous message: hermie: "Re: Function as event handler"
- In reply to: Allen Browne: "Re: Stopping report"
- Next in thread: Allen Browne: "Re: Stopping report"
- Reply: Allen Browne: "Re: Stopping report"
- Messages sorted by: [ date ] [ thread ]