A Microsoft Office (Excel, Word) forum. OfficeFrustration

If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

Go Back   Home » OfficeFrustration forum » Microsoft Access » Running & Setting Up Queries
Site Map Home Register Authors List Search Today's Posts Mark Forums Read  

Parameter Query?



 
 
Thread Tools Display Modes
  #1  
Old July 20th, 2008, 11:38 AM posted to microsoft.public.access.queries
Hank
external usenet poster
 
Posts: 51
Default Parameter Query?

I have a query in access 2003 with the following:

LastName
Birthdate - (example:. 11/01/1990)
Month: Format([Birthdate],"mm") --Expression to extract the month. In the
Criteria I have a parameter: "Enter Month:"
Day: Format([Birthdate],"dd") --Expression - to extract the day

I want is a list of birthdays for a given month.
I get no results when I run the query. I have tried entering "06", "6" and
"Jun" for month. Still no results. There are birthdays in the month I
entered.

What am I doing wrong?
Hank




  #2  
Old July 20th, 2008, 12:33 PM posted to microsoft.public.access.queries
Bob Barrows [MVP]
external usenet poster
 
Posts: 441
Default Parameter Query?

Hank wrote:
I have a query in access 2003 with the following:

LastName
Birthdate - (example:. 11/01/1990)
Month: Format([Birthdate],"mm") --Expression to extract the month.
In the Criteria I have a parameter: "Enter Month:"
Day: Format([Birthdate],"dd") --Expression - to extract the day

I want is a list of birthdays for a given month.
I get no results when I run the query. I have tried entering "06",
"6" and "Jun" for month. Still no results. There are birthdays in
the month I entered.

What am I doing wrong?
Hank

What is the datatype of the birthdate field? is it a Date/Time or a Text
field?

If you remove the criteria and run the query, what does the output of that
Format function look like?


--
Microsoft MVP - ASP/ASP.NET
Please reply to the newsgroup. This email account is my spam trap so I
don't check it very often. If you must reply off-line, then remove the
"NO SPAM"


  #3  
Old July 20th, 2008, 08:25 PM posted to microsoft.public.access.queries
Hank
external usenet poster
 
Posts: 51
Default Parameter Query?


The output of the query is:
Birthdaysqry Last Name Birthdate Month Day
Smith 3/13/1994 03 13
Cramer 11/29/1994 11 29
Long 1/29/1996 01 29
Likus 3/29/1996 03 29
Martin 4/23/1996 04 23
Johnes 5/29/1996 05 29
Applee 8/16/1996 08 16


The datatype from the table source is Date/time formatted to Short date
(mask 99/99/0000;0;_). The Month and Day field are Expressions from the
Birthdate field to sort the month order properly.
The query works fine without criteria. But I want a report of birthdays
for a given month.
While creating this table and query I tried formatting the birthdate as a
Medium Date (27-Jun-69), but I could only sort the months alphabetically.
Changing to Short Date allowed me to sort the months porperly.
Thanks

"Bob Barrows [MVP]" wrote in message
...
Hank wrote:
I have a query in access 2003 with the following:

LastName
Birthdate - (example:. 11/01/1990)
Month: Format([Birthdate],"mm") --Expression to extract the month.
In the Criteria I have a parameter: "Enter Month:"
Day: Format([Birthdate],"dd") --Expression - to extract the day

I want is a list of birthdays for a given month.
I get no results when I run the query. I have tried entering "06",
"6" and "Jun" for month. Still no results. There are birthdays in
the month I entered.

What am I doing wrong?
Hank

What is the datatype of the birthdate field? is it a Date/Time or a Text
field?

If you remove the criteria and run the query, what does the output of that
Format function look like?


--
Microsoft MVP - ASP/ASP.NET
Please reply to the newsgroup. This email account is my spam trap so I
don't check it very often. If you must reply off-line, then remove the
"NO SPAM"



  #4  
Old July 20th, 2008, 09:42 PM posted to microsoft.public.access.queries
Bob Barrows [MVP]
external usenet poster
 
Posts: 441
Default Parameter Query?

Hank wrote:
The output of the query is:
Birthdaysqry Last Name Birthdate Month Day
Smith 3/13/1994 03 13
Cramer 11/29/1994 11 29
Long 1/29/1996 01 29
Likus 3/29/1996 03 29
Martin 4/23/1996 04 23
Johnes 5/29/1996 05 29
Applee 8/16/1996 08 16


The datatype from the table source is Date/time formatted to Short
date (mask 99/99/0000;0;_). The Month and Day field are Expressions
from the Birthdate field to sort the month order properly.
The query works fine without criteria. But I want a report of
birthdays for a given month.


I know. I just wanted to see the output to give us a clue as to what
criterea to enter.

So entering "06" (without the quotes) doesn't work? I think I need to see
the sql statement if so. Switch the query to SQL View (View menu or toobar
button) and copy/paste the sql. It should look something like:

WHERE Format([Birthdate],"mm") = [Enter Month:]



--
Microsoft MVP - ASP/ASP.NET
Please reply to the newsgroup. This email account is my spam trap so I
don't check it very often. If you must reply off-line, then remove the
"NO SPAM"


  #5  
Old July 20th, 2008, 10:13 PM posted to microsoft.public.access.queries
Hank
external usenet poster
 
Posts: 51
Default Parameter Query?

SQL View:
PARAMETERS [Month] Short;
SELECT StudentsTbl.StudentID, StudentsTbl.KnownBy, StudentsTbl.LastName,
StudentsTbl.Birthdate, Format([Birthdate],"mm") AS [Month],
Format([Birthdate],"dd") AS [Day]
FROM StudentsTbl
WHERE (((Format([Birthdate],"mm"))="Enter Month:"))
ORDER BY StudentsTbl.Birthdate, Format([Birthdate],"mm");

"Bob Barrows [MVP]" wrote in message
...
Hank wrote:
The output of the query is:
Birthdaysqry Last Name Birthdate Month Day
Smith 3/13/1994 03 13
Cramer 11/29/1994 11 29
Long 1/29/1996 01 29
Likus 3/29/1996 03 29
Martin 4/23/1996 04 23
Johnes 5/29/1996 05 29
Applee 8/16/1996 08 16


The datatype from the table source is Date/time formatted to Short
date (mask 99/99/0000;0;_). The Month and Day field are Expressions
from the Birthdate field to sort the month order properly.
The query works fine without criteria. But I want a report of
birthdays for a given month.


I know. I just wanted to see the output to give us a clue as to what
criterea to enter.

So entering "06" (without the quotes) doesn't work? I think I need to see
the sql statement if so. Switch the query to SQL View (View menu or toobar
button) and copy/paste the sql. It should look something like:

WHERE Format([Birthdate],"mm") = [Enter Month:]



--
Microsoft MVP - ASP/ASP.NET
Please reply to the newsgroup. This email account is my spam trap so I
don't check it very often. If you must reply off-line, then remove the
"NO SPAM"



  #6  
Old July 20th, 2008, 10:50 PM posted to microsoft.public.access.queries
Bob Barrows [MVP]
external usenet poster
 
Posts: 441
Default Parameter Query?

Hank wrote:
SQL View:
PARAMETERS [Month] Short;


This is wrong. It should say:

PARAMETERS [Enter Month] Text (255);


--
Microsoft MVP - ASP/ASP.NET
Please reply to the newsgroup. This email account is my spam trap so I
don't check it very often. If you must reply off-line, then remove the
"NO SPAM"


  #7  
Old July 21st, 2008, 12:12 AM posted to microsoft.public.access.queries
Hank
external usenet poster
 
Posts: 51
Default Parameter Query?

Sorry, I don't understand.

I replaced "PARAMETERS[Month] Short;" , with "PARAMETERS[Enter Month] Text
(255);" in the SQL view but I still get blank results. ( I dont know what
Text(255); is telling me.)
I tried entering NOV and 11 for November - same results.
If I remove the Crieteria "Enter Month:" in the design view, I am still
prompted to enter a month. Then, no mater what month I enter (Nov or 11),
the results is every birthday in every month.
What did I do wrong?

"Bob Barrows [MVP]" wrote in message
...
Hank wrote:
SQL View:
PARAMETERS [Month] Short;


This is wrong. It should say:

PARAMETERS [Enter Month] Text (255);


--
Microsoft MVP - ASP/ASP.NET
Please reply to the newsgroup. This email account is my spam trap so I
don't check it very often. If you must reply off-line, then remove the
"NO SPAM"



  #8  
Old July 21st, 2008, 12:39 AM posted to microsoft.public.access.queries
Bob Barrows [MVP]
external usenet poster
 
Posts: 441
Default Parameter Query?

The datatype of the parameter (whose name should be the same as the
prompting text) is Text, not numeric (Short).
You should be entering the month number when prompted, but single digit
months should be entered with the leading zero.

You are still getting prompted because you did not remove the parameter
definition when you removed the criterion.

As to what you are doing wrong ... I can't tell. I'm going to go try it
myself ... be right back.



Hank wrote:
Sorry, I don't understand.

I replaced "PARAMETERS[Month] Short;" , with "PARAMETERS[Enter Month]
Text (255);" in the SQL view but I still get blank results. ( I dont
know what Text(255); is telling me.)
I tried entering NOV and 11 for November - same results.
If I remove the Crieteria "Enter Month:" in the design view, I am
still prompted to enter a month. Then, no mater what month I enter
(Nov or 11), the results is every birthday in every month.
What did I do wrong?

"Bob Barrows [MVP]" wrote in message
...
Hank wrote:
SQL View:
PARAMETERS [Month] Short;


This is wrong. It should say:

PARAMETERS [Enter Month] Text (255);


--
Microsoft MVP - ASP/ASP.NET
Please reply to the newsgroup. This email account is my spam trap so
I don't check it very often. If you must reply off-line, then remove
the "NO SPAM"


--
Microsoft MVP - ASP/ASP.NET
Please reply to the newsgroup. This email account is my spam trap so I
don't check it very often. If you must reply off-line, then remove the
"NO SPAM"


  #9  
Old July 21st, 2008, 12:43 AM posted to microsoft.public.access.queries
Bob Barrows [MVP]
external usenet poster
 
Posts: 441
Default Parameter Query?

Hank wrote:
Sorry, I don't understand.

I replaced "PARAMETERS[Month] Short;" , with "PARAMETERS[Enter Month]
Text (255);" in the SQL view but I still get blank results. ( I dont
know what Text(255); is telling me.)
I tried entering NOV and 11 for November - same results.
If I remove the Crieteria "Enter Month:" in the design view, I am
still prompted to enter a month. Then, no mater what month I enter
(Nov or 11), the results is every birthday in every month.
What did I do wrong?


Well, it seems to work for me. Here is my query:
PARAMETERS [Enter Month] Text ( 255 );
SELECT Table1.Field1, Table1.ID, Table1.VendorCtry, Table1.VendDate
FROM Table1
WHERE (((Format([VendDate],"mm"))=[Enter Month]));

When I enter 11, I get November dates. When I enter 06, I get June dates.

I don't know what else I can tell you.


--
Microsoft MVP - ASP/ASP.NET
Please reply to the newsgroup. This email account is my spam trap so I
don't check it very often. If you must reply off-line, then remove the
"NO SPAM"


  #10  
Old July 21st, 2008, 01:00 AM posted to microsoft.public.access.queries
Bob Barrows [MVP]
external usenet poster
 
Posts: 441
Default Parameter Query?

Hank wrote:
Sorry, I don't understand.

I replaced "PARAMETERS[Month] Short;" , with "PARAMETERS[Enter Month]
Text (255);" in the SQL view but I still get blank results. ( I dont
know what Text(255); is telling me.)
I tried entering NOV and 11 for November - same results.
If I remove the Crieteria "Enter Month:" in the design view, I am
still prompted to enter a month. Then, no mater what month I enter
(Nov or 11), the results is every birthday in every month.
What did I do wrong?

"Bob Barrows [MVP]" wrote in message
...
Hank wrote:
SQL View:
PARAMETERS [Month] Short;


This is wrong. It should say:

PARAMETERS [Enter Month] Text (255);



Instead of requiring your users to enter the leading zeroes, you might try
using the Month() function instead:

PARAMETERS [Enter Month] Short;
SELECT StudentsTbl.StudentID, StudentsTbl.KnownBy, StudentsTbl.LastName,
StudentsTbl.Birthdate,
Month([Birthdate]) AS [Month],
Format([Birthdate],"dd") AS [Day]
FROM StudentsTbl
WHERE Month([Birthdate])=[Enter Month:]
ORDER BY StudentsTbl.Birthdate, Format([Birthdate],"mm");

Now all the user has to enter for June dates is 6, instead of 06.

And I just saw what you were doing wrong: you had
WHERE (((Format([Birthdate],"mm"))="Enter Month:"))

And you should have had:
WHERE (((Format([Birthdate],"mm"))=[Enter Month:]))








--
Microsoft MVP - ASP/ASP.NET
Please reply to the newsgroup. This email account is my spam trap so I
don't check it very often. If you must reply off-line, then remove the
"NO SPAM"


 




Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Forum Jump


All times are GMT +1. The time now is 11:22 AM.


Powered by vBulletin® Version 3.6.4
Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 OfficeFrustration.
The comments are property of their posters.