473,396 Members | 1,852 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,396 software developers and data experts.

How to pass parameters from Form to Reports?

1
Hi

I want to ask...

A report is using a query as record source.
That query has parameters [StartDate] and [EndDate].
A command button in a form open that report.
That form contains 2 textbox for date.

How can I pass this 2 textbox as the parameters of the query?

Query:
SELECT * FROM Orders WHERE Orders.[Date/Time] Between [StartDate] And [EndDate]

I am still learning MS Access, so please tell me if there is another way...
Feb 8 '07 #1
3 5206
MMcCarthy
14,534 Expert Mod 8TB
Change report query to ...

Expand|Select|Wrap|Line Numbers
  1.  SELECT * FROM Orders;
Command button to open the report
Expand|Select|Wrap|Line Numbers
  1. Private Sub cmdBtnName_Click()
  2. Dim stDocName As String
  3. Dim stLinkCriteria As String
  4.  
  5.   stDocName = "ReportName"
  6.   stLinkCriteria = "[Date/Time] Between " & Me.StartDate & " And " & Me.EndDate
  7.   DoCmd.OpenReport stDocName, , , stLinkCriteria
  8.  
  9. End Sub
  10.  
Feb 8 '07 #2
nico5038
3,080 Expert 2GB
Just adding to the above comment that you need to construct a form with two textboxes, named Startdate and EndDate (See the Name property under the Other tab of the properties for those fields) and a button to trigger the code.

Nic;o)
Feb 8 '07 #3
NeoPa
32,556 Expert Mod 16PB
You should replace the stLinkCriteria line of Mary's code with :
Expand|Select|Wrap|Line Numbers
  1.   stLinkCriteria = "[Date/Time] Between " & _
  2.                    Format(Me!StartDate,"\#m/d/yyyy\#") & _
  3.                    " And " & _
  4.                    Format(Me!EndDate,"\#m/d/yyyy\#")
Feb 10 '07 #4

Sign in to post your reply or Sign up for a free account.

Similar topics

1
by: longtim | last post by:
I have been having endless difficulty creating reports/queries that set any relevent parameters from controls in forms. I am creating an application under access 2003 but will target access...
7
by: Zlatko Matić | last post by:
Let's assume that we have a database on some SQL server (let it be MS SQL Server) and that we want to execute some parameterized query as a pass.through query. How can we pass parameters to the...
0
by: Zlatko Matić | last post by:
Hi everybody! Recently I was struggling with client/server issues in MS Access/PostgreSQL combination. Although Access is intuitive and easy to use desktop database solution, many problems...
9
by: Jay Douglas | last post by:
Hello, I am needing to pass a class object (this) by reference to a method in a different class. When I do the following code I get the error (Cannot pass '<this>' as a ref or out argument because...
9
by: Robert Schuldenfrei | last post by:
Hello NG, After a bit of a wait my bookstore, SoftPro of Waltham, MA, got in the Brian Bischof book: Crystal Reports .NET Programming. I have read a few books on CR, but I am very new to it,...
3
by: Don Wash | last post by:
Hi There! I've posted a few days back about this issue but no solutions has been found and that's why I'm re-posting this. I'm using built-in CrystalReport that comes with VS.NET 2003 to...
3
by: Nancy | last post by:
I have the following scenario. I have some Crystal Reports that were created outside the .NET Visual Studio. These reports were designed to enter date parameters. I have developed a ASP.NET app...
2
by: Dean Slindee | last post by:
I would like to pass multiple parameters from a VB.NET application to an existing Access 2003 application's reports (essentially using Access as a report writer where the reports already exist)....
0
by: Dean Slindee | last post by:
I would like to pass multiple parameters from a VB.NET application to an existing Access 2003 application's reports (essentially using Access as a report writer where the reports already exist)....
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.