473,466 Members | 1,290 Online
Bytes | Software Development & Data Engineering Community
Create Post

Home Posts Topics Members FAQ

Input Parameter for Query

132 New Member
I know you can allow a user to type in a parameter during a query. However, how can one limit the choices by using a drop down or list box?

Here is an example of what I am trying to do: In the Country field of the customers table I can have the following in the criteria section:

[Enter a Country]

When this query executes, the user enters a country and the results are shown.
Is there a way to make this a drop down box or list box with pre-defined choices instead of allowing the user to freely type a parameter?
Aug 30 '07 #1
13 3109
Rabbit
12,516 Recognized Expert Moderator MVP
Not with the parameter request box. Usually, we'll do this by having an intermediary form.
Aug 30 '07 #2
Proaccesspro
132 New Member
Not with the parameter request box. Usually, we'll do this by having an intermediary form.

Can you provide a link to some examples??
Aug 30 '07 #3
Denburt
1,356 Recognized Expert Top Contributor
Try utilizing a search form then you can use that to open the record you are requesting...

http://www.thescripts.com/forum/thread590551.html

Let me know if that helps. I have a couple of functions I use for rebuilding queries but I don't think you want to go that route it can get a bit complex.
Aug 30 '07 #4
Proaccesspro
132 New Member
Try utilizing a search form then you can use that to open the record you are requesting...

http://www.thescripts.com/forum/thread590551.html

Let me know if that helps. I have a couple of functions I use for rebuilding queries but I don't think you want to go that route it can get a bit complex.
I'll check it out, Thanks.....

Is there a parameter function I can use to determine what "orders" are X number of days old??? In other words, the user would inut a number, say 45, and the query would then list all of the corresponding order that are 0 to 45 days old.
Aug 30 '07 #5
Proaccesspro
132 New Member
I'll check it out, Thanks.....

Is there a parameter function I can use to determine what "orders" are X number of days old??? In other words, the user would inut a number, say 45, and the query would then list all of the corresponding order that are 0 to 45 days old.
Let me clarify further. I have a date field in a table. I want to allow the user to input a number and the query use that number to determine how many order are up to that many days old....

the following code in the criteria line of a query will prompt the user for a beginning and end date...I want to do something similar, but based on a single input for number of days.

between [enter a start date] AND [enter an end date]
Aug 30 '07 #6
Denburt
1,356 Recognized Expert Top Contributor
Yeah you will need to write some code to determine what you are looking for.

If DateDiff("d", Now, TheDate) < 45 then
showRecords()
End if
Aug 30 '07 #7
Denburt
1,356 Recognized Expert Top Contributor
Let me clarify further. I have a date field in a table. I want to allow the user to input a number and the query use that number to determine how many order are up to that many days old....

the following code in the criteria line of a query will prompt the user for a beginning and end date...I want to do something similar, but based on a single input for number of days.

between [enter a start date] AND [enter an end date]
O.K. then do this

in a field name in the Query add this
DaysOld:DateDiff("d", Now, TheDate)

Then in the criteria of that field you can ask for the number of days [Number Of Days] or just specify <45
Aug 30 '07 #8
Proaccesspro
132 New Member
O.K. then do this

in a field name in the Query add this
DaysOld:DateDiff("d", Now, TheDate)

Then in the criteria of that field you can ask for the number of days [Number Of Days] or just specify <45
Almost...can I substitute a field in my table (called date recvd) for Thedate?? I actually want to calculate the number of days the user inputs minus the field Date recvd. Then grab the records of those that meet that criteria.
Aug 30 '07 #9
Denburt
1,356 Recognized Expert Top Contributor
O.K. then do this

in a field name in the Query add this
DaysOld:DateDiff("d", Now, [date recvd])

That will give you a column of numbers thus calculating the days before the users input then when the person inputs a number you control how it is used < for less than > greater than etc.

In the criteria of that field you can ask for the number of days
You can specify <[Number Of Days] and get the prompt then they input the number of days or an = sign etc. or just specify <45 or something along those lines.


I don't want to confuse you but another method would be to use the field you have called [date recvd] in the criteria section add the following (this one is off the top of my head should work though).

dateadd("d",-[How many Days],Date())

Good luck and goodnight for now.
Aug 30 '07 #10
Proaccesspro
132 New Member
O.K. then do this

in a field name in the Query add this
DaysOld:DateDiff("d", Now, [date recvd])

That will give you a column of numbers thus calculating the days before the users input then when the person inputs a number you control how it is used < for less than > greater than etc.

In the criteria of that field you can ask for the number of days
You can specify <[Number Of Days] and get the prompt then they input the number of days or an = sign etc. or just specify <45 or something along those lines.


I don't want to confuse you but another method would be to use the field you have called [date recvd] in the criteria section add the following (this one is off the top of my head should work though).

dateadd("d",-[How many Days],Date())

Good luck and goodnight for now.
Both ways execute, but neither produces any records!!!!

Am I correct in thinking that both ways are looking for dates that will MATCH the current date minus the number input by the user?? In other words, today is the 30th...so if someone types in 5 as the parameter, does the function then go out and look for orders received 5 days prior to today? If so, that is not what I want to do. Instead, I would want to see ALL orders received over the last 5 days (the number typed in by the user).
Aug 30 '07 #11
Denburt
1,356 Recognized Expert Top Contributor
O.K. My brain isn't what it used to be. I ran a few tests and my conclusion is that in the field [date recvd] you should add the following criteria and it should work as expected..

>=DateAdd("d",-[How many Days],Date())
Aug 31 '07 #12
Proaccesspro
132 New Member
O.K. My brain isn't what it used to be. I ran a few tests and my conclusion is that in the field [date recvd] you should add the following criteria and it should work as expected..

>=DateAdd("d",-[How many Days],Date())

Works like a top!! Thanks!!
Sep 4 '07 #13
Denburt
1,356 Recognized Expert Top Contributor
Works like a top!! Thanks!!
Glad we could help, have a nice day.
Sep 5 '07 #14

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

Similar topics

8
by: rgonzale6 | last post by:
Hello. I'm using SQL query analyzer to run some queries against an SQL2000 DB. Unfortunately, my previous SQL experience is some Oralce SQL I took in school. To put it simply, I'm trying to...
2
by: JBrow | last post by:
I have a query that asks for 3 sets of parameters. Works fine until I have a second query which uses this query as its source. When I fire the second query, the user is prompted for the 3 input...
2
by: PerryC | last post by:
Is there a way to set a certain format under the Query Criteria for input? i.e.: As user type 200000000, 200-00-0000 is displayed in the query input box. However, 20000000 is the actual value...
2
by: lgo | last post by:
I have read several variations of this topic posted on this news group. However I was not able to find the answer for my problem. I am trying to build code (see below) to update a large single...
1
by: carrionk | last post by:
Hi, I have created a Subform which SourceObject is a parameter query. This is the Query: Qry Name:80IsscomProduct SELECT * FROM Isscomp28 WHERE Like ;
2
by: gritter55 | last post by:
I have a parameter query in Access 97 that working for 99% of my users. But for 2 of them, when they run it, it skips over the input box (they never see it) and simply returns an empty set. I...
8
by: FS Liu | last post by:
Hi, I am writing ATL Service application (XML Web service) in VS.NET C++. Are there any sample programs that accept XML as input and XML as output in the web service? Thank you very much.
4
by: kjworm | last post by:
Hello everyone. I have a parameter query that I would like to retain the parameter value for future use. What I would like to do is have the user perform the query, select the distinct result that...
1
by: TonyJH | last post by:
Hello, I have a database in Access2003. I have set up several queries that use the parameter entry . Each query produces different outputs from various tables that go into a report. Sometimes, a...
1
by: katwheels | last post by:
I need to convert a data element from a web page table into an MS Access input parameter and then run another MS Access query. I have an ASP web page that generates an MS Access query and creates...
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...
1
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
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,...
0
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...

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.