473,406 Members | 2,763 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,406 software developers and data experts.

Having difficulty creating reports with query parameters set from form controls

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
2000. The access file is in access 2000 format.

I have a form that will hold the relevent parameters for the
query/report that reports the statistics for all job records that
match a certain criteria. These are:
- A Customer Name.
- An Internal department.
- Start date (job must have been created after this date).
- End date (job must have been created before this date).

I have created the form that has two drop down lists, one containing
all customers in the database and the other containing all department
names. There are also two unbound text boxes on the field that hold
the start and end date for the query/report.

I have created a test query that lists all records that will match the
revelvent parmaters.

The base query displays:
- Job Number.
- Creation Date.
- AccountID (matches Customer Name).
- Identifier Department.

Everything works with the following setup (the query returns records)
with the critera field on the form set to:

AccountID : [Forms]![frmEnterCustAct]![AccountID]
Identifier Department : [Forms]![frmEnterCustAct]![IdDepart]

(frmEnterCustAct is the form that holds the input parameters).

Getting the date field right is more problematic. I have discovered
that the following will NOT work in the critera field for Creation
date in the query

Creation Date: >[Forms]![frmEnterCustAct]![TxtStartDate]

BUT THE FOLLOWING DOES WORK

Creation Date: >[Forms]![frmEnterCustAct]![TxtStartDate].[text]

Does anybody know why the criteria field must explicitly be set to the
text of the control?

When I set the criteria field for the Creation Date to field to what
should be its proper value:

Creation Date: >[Forms]![frmEnterCustAct]![TxtStartDate].[text] And
<[Forms]![frmEnterCustAct]![TxtEndDate].[Text]

This doesn't work. The query returns no records.

I have tried a number of ways around this problem involving using VBA
to set the query parameters from the On Open event in the report that
will open the query. I don't want to use DAO for this, only ADO. There
appears to be total lack of documentation that explains the interface
between the access queries and underlying ADO data object model that
allows the user to set the Query parameters of a report. Does anyone
know a reference to this. All the group threads I have read talk
abount DAO QueryDefs as the way to go.

I am at my wits end.

Thanks In advance.
Nov 13 '05 #1
1 2886
lo*****@iinet.net.au wrote:
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
2000. The access file is in access 2000 format.

I have a form that will hold the relevent parameters for the
query/report that reports the statistics for all job records that
match a certain criteria. These are:
- A Customer Name.
- An Internal department.
- Start date (job must have been created after this date).
- End date (job must have been created before this date).

I have created the form that has two drop down lists, one containing
all customers in the database and the other containing all department
names. There are also two unbound text boxes on the field that hold
the start and end date for the query/report.

I have created a test query that lists all records that will match the
revelvent parmaters.

The base query displays:
- Job Number.
- Creation Date.
- AccountID (matches Customer Name).
- Identifier Department.

Everything works with the following setup (the query returns records)
with the critera field on the form set to:

AccountID : [Forms]![frmEnterCustAct]![AccountID]
Identifier Department : [Forms]![frmEnterCustAct]![IdDepart]

(frmEnterCustAct is the form that holds the input parameters).

Getting the date field right is more problematic. I have discovered
that the following will NOT work in the critera field for Creation
date in the query

Creation Date: >[Forms]![frmEnterCustAct]![TxtStartDate]

BUT THE FOLLOWING DOES WORK

Creation Date: >[Forms]![frmEnterCustAct]![TxtStartDate].[text]

Does anybody know why the criteria field must explicitly be set to the
text of the control?

When I set the criteria field for the Creation Date to field to what
should be its proper value:

Creation Date: >[Forms]![frmEnterCustAct]![TxtStartDate].[text] And
<[Forms]![frmEnterCustAct]![TxtEndDate].[Text]

This doesn't work. The query returns no records.

I have tried a number of ways around this problem involving using VBA
to set the query parameters from the On Open event in the report that
will open the query. I don't want to use DAO for this, only ADO. There
appears to be total lack of documentation that explains the interface
between the access queries and underlying ADO data object model that
allows the user to set the Query parameters of a report. Does anyone
know a reference to this. All the group threads I have read talk
abount DAO QueryDefs as the way to go.

I am at my wits end.

Thanks In advance.


Dates are the date + 0 hour, 0 minutes, 0 seconds. If you store a value
like Now() to the date field ex: (9/6/04 13:01:02) and you want to get
records between 9/5/04 and 9/6/04, this record would not be in the list
since 13:01:02 is greater than 00:00:00. So IF you are using date/time
stamps, you'd want to select records between 9/5/04 and 9/7/04 since
that would now fall between 9/5/04 00:00:00 and 9/7/04 00:00:00

But to address your problem. Try something like this in your form for 1
of several alternatives. I also use >= since you might be wanting
records that are greater or equal to the date. Also, be aware that if
you are using dates, but the values are a date/time stamp, you need to
adjust the time.
Private Function PrintReport()
'remember, dates surrounded by #'s,
'alphanumerics by quotes, numbers aren't surrounded.
Dim strWhere As String
If Not IsNull(Me.TxtStartDate) Then
strWhere = "[Creation Date] >= #" & _
Me.TxtStartDate & "#"
ENdif
If Not IsNull(Me.TxtEndDate) Then
If strWhere > "" Then strWhere = strWHere & " And "
strWhere = strWhere & "[Creation Date] <= #" & _
Me.TxtEndDate & "#"
ENdif
'pass the date filters when command button to present report
'is pressed.
Docmd.OpenReport "YourReportName",,,strWhere
End Sub
Nov 13 '05 #2

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
by: Joris Kempen | last post by:
Hi people, I know that the question has come around sometimes: How to open an Access Report using ASP and export it to for example RTF. I'm trying to implement the first method of David...
2
by: Cassie Pennington | last post by:
I am using VBA to determine which query sits behind a report, depending upon the preferred sort order. This has worked perfectly for ordinary select queries behind reports, but it seems to be...
1
by: Fred Zuckerman | last post by:
I have 8 reports that I want to run. Each report is only about 6-7 lines long. I'd like to get them all on a single page. So I created a parent report and made each of the 8 desired reports a...
3
by: bcaponet | last post by:
I have a form where a user enters a date that I will then base a query on. In the past, I have simply placed Forms!! into the criteria for a query and it runs as long as the form is open. The...
4
by: Andy Davis | last post by:
I have developed a number of reports that are based on parameter queries where the user enters criteria such as a date range and a sales rep say. I want to be able to show a graphical picture in...
0
by: Henry | last post by:
Using ideas provided by some of you I was able to figure out how to get the names of the parameters fields of a crystal report specified at run time. The code below just basically puts the...
7
by: Jlo | last post by:
Hi, I have a c# winforms application. When I call the report file, it shows me all the records in the table. How can I make it to call only a particular range. i have the following code...
0
by: Albert D. Kallal | last post by:
Use the "where" clause, and make the reports sql *without* any parameters..and you not need to change the params.. So, you can build a un-bound form (a un-bound form is a form that is NOT...
7
by: google | last post by:
I am trying to automate the way reports are printed in an Access 2003 database - I have ~200 records (people) who require between 5 and 10 customized reports (depending on values within certain...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
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
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
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
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
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...

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.