Wrox Programmer Forums
Go Back   Wrox Programmer Forums > Microsoft Office > Access and Access VBA > Access
|
Access Discussion of Microsoft Access database design and programming. See also the forums for Access ASP and Access VBA.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the Access section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old February 24th, 2005, 07:47 PM
Friend of Wrox
 
Join Date: Aug 2003
Posts: 137
Thanks: 0
Thanked 0 Times in 0 Posts
Default Passing Query Inputs To Reports

I am developing an Access 2000 database, which uses Macros to control input forms that then pass inputted data to a query to produce the desired Report output.

Although not part of the final report, the user is required to enter a date range as part of the query. I was wondering whether it was possible to pass that dates entered to the report some how to enable to produce a report that has a title like "REPORT...FOR 12/12/2000 to 12/12/2002"

Is that possible?


Gaz
__________________
Gaz
 
Old February 24th, 2005, 08:30 PM
Authorized User
 
Join Date: Dec 2004
Posts: 48
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Hi,
  If my understand is right. You can use a form to request the user to enter the date then pass the data to the report. In the report, you
can use a txtbox which is bounded to the field in the form. Meanwhile you also need to filter the data in the query of the report ny using "Like" command. I hope this would work for you.

flyfish
 
Old February 25th, 2005, 03:11 AM
Authorized User
 
Join Date: Feb 2005
Posts: 34
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Hello socoolbrewster

Everything is possible...if you know how! What you need, I do all the time. There are many flavours of the technique so here's the general idea.

Add a label control in a section of your report and name it (here it is lblTheDates).

In the OnOpen event of the report add some code like this (adapting it to your situation):

Private Sub Report_Open(Cancel As Integer)
    Dim frm As Form
    Set frm = Forms("frmYourInputForm")

    Me!lblTheDates.Caption = "From " & _
         Format(frm.txtDateFrom, "dd-mmmm-yy") & " to " & _
         Format(frm.txtDateTo, "dd-mmmm-yy")
End Sub

So, when the report opens (the form is still open) it creates an object variable frm pointing to the opened form frmYourInputForm. Then it reads the two dates in the TextBoxes txtDateFrom and txtDateTo on the form and concatenates the whole thing is a sentence.

So if the first box has 2/12/05 and the second one has 3/21/05 the procedure will write in the Caption of the Label:

From 12-February-05 to 21-March-05

You will have fun, though, validating the two entries to make sure they are dates or even that the two text boxes contain something.

Let me know about your progress.

Daniel
 
Old February 25th, 2005, 08:35 AM
Friend of Wrox
 
Join Date: Mar 2004
Posts: 3,069
Thanks: 0
Thanked 10 Times in 10 Posts
Default

I would just like to say, "Macros!?!"

:D

mmcdonal
 
Old February 25th, 2005, 12:59 PM
Friend of Wrox
 
Join Date: Mar 2004
Posts: 3,069
Thanks: 0
Thanked 10 Times in 10 Posts
Default

To clarify, that was meant to be funny. I didn't realize anyone was still using macros. Just a quip, though. Not meant to be mean.

mmcdonal





Similar Threads
Thread Thread Starter Forum Replies Last Post
passing parameters to crystal reports Shubhi ASP.NET 2.0 Professional 0 July 4th, 2008 02:18 AM
Passing Parameters to crystal reports through codi secrets Crystal Reports 0 April 5th, 2005 01:44 PM
Passing parameters w/o prompt to Crystal reports VannAustin VB How-To 0 March 2nd, 2005 02:16 AM
Dynamic sub-reports with parameter passing safecoder Crystal Reports 0 October 27th, 2004 12:26 PM
Passing parameters to reports jammykam Access 2 October 8th, 2003 02:24 PM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.