|
 |
access thread: Re: Passing a string to a report label.
Message #1 by gaziz@s... on Mon, 27 May 2002 08:24:28
|
|
> I am learning VBA via Beginning Access 2000 VBA. I am working through the
> exercises in chpt 7. I would like to be able to pass the "strWhere"
> string (it contains part of the SQL) to the report that is ultimately
> created. I would like to put this in the report so that it tells what the
> criteria are for the report creation. I am new at this type of
> programming. It is probably easy, I just have not found any examples. I
> would like to put it in the Report label or in a text field. How?
Message #2 by "Paul Winter" <p.winter@s...> on Mon, 27 May 2002 14:40:35
|
|
You could pass the strWhere string in the OpenArgs parameter of
DoCmd.OpenReport . You can then use code like
if not isNull(Me.openargs) Then
Me.lblTest = Me.openargs
End if
HTH
Paul
> > I am learning VBA via Beginning Access 2000 VBA. I am working through
the
>> exercises in chpt 7. I would like to be able to pass the "strWhere"
>> string (it contains part of the SQL) to the report that is ultimately
>> created. I would like to put this in the report so that it tells what
the
>> criteria are for the report creation. I am new at this type of
>> programming. It is probably easy, I just have not found any examples.
I
>> would like to put it in the Report label or in a text field. How?
Message #3 by "Charlie Goodwin" <cgoodwin@c...> on Mon, 27 May 2002 16:51:25
|
|
I have a very low tech way to make criteria for a report available to a
report:
I summon up many reports based on data from unbound forms with text boxes
with, say, start and complete dates, or IDs for recipients etc. The user
will enter, for example, "between" dates etc in those boxes.
Those boxes might be named something like TxtStartDate, and TxtEndDate.
The form will have a button to open a query that uses those date values as
criteria to select records of, say, transactions between those dates. In
the query criteia line I use text like
Between [Forms]![FrmYOURFORMNAME]![TxtStartDate] And [Forms]!
[FrmYOURFORMNAME]![TxtEndDate]
The button also subsequently opens the report.
On the report you can use items such as the value of [Forms]!
[FrmYOURFORMNAME]![TxtStartDate] as RecordSources
One textbox on one of my reports shows data from:
="Transaction number " & [TransID] & " chosen from transactions occurring
between " & [Forms]![FrmA2DatePanel]![TxtStartDate] & " and " & [Forms]!
[FrmA2DatePanel]![TxtEndDate]
[TransID] is obtained by the report from the query, and the two dates are
obtained from the criteria form.
Which will generate text visible on the report like:
Transaction number129 chosen from transactions occurring between 12/24/02
and 1/3/03
The form that makes the criteria available is left open so that the report
can grab critera items directly from the form as well as from the query.
The query is closed on the Close event for the report.
A message box is summoned on the no data event to prompt the user to set
criteria values if they enter no data, but attempt to generate the report.
Those kind of text boxes can be placed to "label" other textboxes in your
report to get the fuctionality I think you want.
All this is very low tech.... nothing I've mentioned here needs anything
fancier than macros for basic apps...and I'm sure it all can be elaborated
further for more involved uses. Perhaps this can be adapted to suit your
needs.
Charlie
**************************
> You could pass the strWhere string in the OpenArgs parameter of
D> oCmd.OpenReport . You can then use code like
> if not isNull(Me.openargs) Then
> Me.lblTest = Me.openargs
E> nd if
> HTH
P> aul
>
>> > I am learning VBA via Beginning Access 2000 VBA. I am working
through
t> he
>> > exercises in chpt 7. I would like to be able to pass the "strWhere"
>> > string (it contains part of the SQL) to the report that is
ultimately
>> > created. I would like to put this in the report so that it tells
what
t> he
>> > criteria are for the report creation. I am new at this type of
>> > programming. It is probably easy, I just have not found any
examples.
I>
>> > would like to put it in the Report label or in a text field. How?
Message #4 by "Gregory Serrano" <SerranoG@m...> on Tue, 28 May 2002 22:01:11
|
|
<< I would like to be able to pass the "strWhere" string (it contains part
of the SQL) to the report that is ultimately created. I would like to put
this in the report so that it tells what the criteria are for the report
creation. >>
The criteria for the report can usually be found in the Filter property of
the report after it opens. Create a textbox, for example txtRptCriteria,
in your report and put this on the report's "On Open" event:
Me.txtRptCriteria = Me.Filter
Make sure the text box has lots of room (255 is the max). The criteria
statement may get quite long. Better yet, make it a memo field.
Greg
Message #5 by "Wesley Kendrick" <wez.k@n...> on Mon, 27 May 2002 22:57:37 +0100
|
|
1. Open the report in design view
2. Insert a text field (not a label) wherever you want it.
3. Right click on the section of the report that your new field is in and
select 'Properties' from the menu that opens.
4. Select Events|OnFormat and select Event Procedure form the list
5. Click on the button at the far right of the OnFormat row to open the
VB editor and create the procedure.
6. Type in 'YourNewField = strWhere' If strWhere is on a form, you will
need the ful syntax, ie Forms!YourForm!strWhere
7. Go back to the report and go to view mode - your text field should
appear with the value of strWhere.
Regards, Wesley Kendrick
----- Original Message -----
From: <gaziz@s...>
To: "Access" <access@p...>
Sent: Monday, May 27, 2002 8:24 AM
Subject: [access] Re: Passing a string to a report label.
> > I am learning VBA via Beginning Access 2000 VBA. I am working through
the
> > exercises in chpt 7. I would like to be able to pass the "strWhere"
> > string (it contains part of the SQL) to the report that is ultimately
> > created. I would like to put this in the report so that it tells what
the
> > criteria are for the report creation. I am new at this type of
> > programming. It is probably easy, I just have not found any examples. I
> > would like to put it in the Report label or in a text field. How?
>
|
|
 |