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

How to access the user's input (to a crosstab query) as a field?

sueb
379 256MB
I have a crosstab query that gathers all records for a fiscal year specified by the user's input, then counts the number of records that fall within a specific month, grouped by a discriminant in those records. It's my Surgery database, so I ask the user to enter the 4-digit year that begins the fiscal year; then I calculate the beginning/ending dates for the FY and use those to filter Date of Surgery; then I count the number of records (just using the AutoNumber field) for each Service (General, Ob-Gyn, etc.), grouping them by month.

Here's the SQL as it stands:

Expand|Select|Wrap|Line Numbers
  1. TRANSFORM Count(DataTable.Number) AS CountOfNumber
  2. SELECT DataTable.Service, Count(DataTable.Number) AS [Total Of Number]
  3. FROM DataTable
  4. WHERE (((DataTable.[Date of Surgery]) Between CDate("7/1/" & [Enter FY Start Year (yyyy)]) And CDate("6/30/" & ([Enter FY Start Year (yyyy)]+1))))
  5. GROUP BY DataTable.Service, [Enter FY Start Year (yyyy)] & ([Enter FY Start Year (yyyy)]+1)
  6. PIVOT Format([date of surgery],"mmm") In ("Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec");
  7.  
and I've attached a page of the report for visual reference.

For the life of me, I can't seem to get the entered Fiscal Year to show up as a field that I can print in the report's title. I've tried a couple of different things, including "making a field of it" in a separate (Expression) column:

Expand|Select|Wrap|Line Numbers
  1. FY: [Enter FY Start Year (yyyy)]
but that simply disappears when I re-open the query. It doesn't even object to it, but simply refuses to recognize it.
Attached Files
File Type: zip VCMC Surgery Case Count by FY.zip (40.3 KB, 3 views)
May 3 '11 #1

✓ answered by Stewart Ross

Hi Sue. In your query the user-entered parameter is not available as a field for you to refer to. It is part of the WHERE clause of your SQL, and you will not be able to retrieve it as a value unless you list it also in the fields you select.

In general it is not good practice to use such parameter queries as the basis for a report at all. The user has no guide as to the form of the value required, and in any event you already have values in your tables which you should be able to show to your users in the form of a pick-list from which they select a value.

Accordingly, I suggest that you design a user-form with a combo box providing a drop-down list for the user to select the relevant year before opening the report on the click of a command button. There are many good examples of how to do this kind of thing around, including in the NorthWind example database available as part of your MS Access installation (or separately downloadable if you do not have direct access to it).

You will find lots of useful techniques on designing good user interfaces like this in books such as Building Microsoft Access Applications by John L. Viescas, which I can recommend you read.

-Stewart

2 3788
Stewart Ross
2,545 Expert Mod 2GB
Hi Sue. In your query the user-entered parameter is not available as a field for you to refer to. It is part of the WHERE clause of your SQL, and you will not be able to retrieve it as a value unless you list it also in the fields you select.

In general it is not good practice to use such parameter queries as the basis for a report at all. The user has no guide as to the form of the value required, and in any event you already have values in your tables which you should be able to show to your users in the form of a pick-list from which they select a value.

Accordingly, I suggest that you design a user-form with a combo box providing a drop-down list for the user to select the relevant year before opening the report on the click of a command button. There are many good examples of how to do this kind of thing around, including in the NorthWind example database available as part of your MS Access installation (or separately downloadable if you do not have direct access to it).

You will find lots of useful techniques on designing good user interfaces like this in books such as Building Microsoft Access Applications by John L. Viescas, which I can recommend you read.

-Stewart
May 3 '11 #2
sueb
379 256MB
Oh, yes, Stewart, of course this is how to do this! (so obvious once it's said...)

In addition, I'm very grateful for the recommendation of a good book. I don't have an adequate one, and haven't been able to tell (just from reading reviews on Amazon) which to buy. Double thanks for that!
May 3 '11 #3

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

Similar topics

8
by: Donna Sabol | last post by:
First, I should start by saying I am creating a database to be used by some very impatient, non-computer literate people. It needs to be seameless in it's operation from their point of view. I...
4
by: No Spam | last post by:
Dear Access 2000 users, I have a crosstab query that puts together certain information perfectly. It has a criteria that is based on a form that limits how many columns are returned based on...
4
by: Judy | last post by:
I'm using Access 2003 and was wondering if it is possible to have a paramater selection within a crosstab query so that I wouldn't need to build a new table. I have a select query that I'm using...
2
by: x | last post by:
hi i have made a crosstab query in which row heading is "date", colum heading is "aircraft type" and the value to be summed up is "1-10 row totals". i want to create a simple query which should...
2
by: Keith Wilby | last post by:
I have a report that is based upon a crosstab query which return only the columns (fields) it has data for. When my report runs it sometimes fails because some of the text boxes don't have a field...
3
by: Mike | last post by:
Hi, Im trying to create a crosstab query with fewer than 255 headings (about 50), but it crashes when I try to save after writing the heading names in the query property "column headings". My...
3
by: russellhq | last post by:
Hi, I'm fairly new to access and have a little trouble with a crosstab query I've setup. I have a main form where the user selects a project name and below in a subform, a crosstab query is...
19
by: Coastie | last post by:
Good afternoon- There is a table with the following fields: PK*, Equipment_ID, Battery_Serial *= arbitrary primary key Each piece of equipment has between 0 and 3 batteries, and each battery...
8
by: Paul H | last post by:
I want to base a form on a crosstab query. The query shows statistics for a user defined period. The column headings will look something like this: ClientID Month01 Month02 Month03 etc.. ...
2
by: Jim Devenish | last post by:
I wish to create a crosstab query as the record source for a report. It needs to count data between selected dates which are entered by the user in a popup window. The following Select query...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
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...
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
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
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
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
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...

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.