Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

Access 2010 Query default value

Posted on 2011-09-05
13
Medium Priority
?
341 Views
Last Modified: 2012-05-12
So, i have a basic form from query. In my query (from mem) i have the following code.
I would like to have a date default in this box...  how do I set the default input?

I have many other fields like [OS]  I would to default to say e.g "Windows 7"


like "*" & [Enter Date] & "*"

Open in new window

0
Comment
Question by:myhc
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 6
  • 4
  • 2
  • +1
13 Comments
 
LVL 120

Expert Comment

by:Rey Obrero (Capricorn1)
ID: 36485874

for default values( criteria)

where [OS]="Windows 7"


in graphical view


field      [OS]
table     NameOftable

Criteria  "Windows 7"
0
 
LVL 7

Author Comment

by:myhc
ID: 36485892
This picks 7. I want it to prompt with default of win 7
0
 
LVL 120

Expert Comment

by:Rey Obrero (Capricorn1)
ID: 36485919
if you want a prompt, you have to type in the value ...

field      [OS]
table     NameOftable

Criteria  [Enter OS]


0
Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
LVL 7

Author Comment

by:myhc
ID: 36485927
So you can't have a prompt with a defult value. I'm sure you could fo this in 2003...
0
 
LVL 120

Expert Comment

by:Rey Obrero (Capricorn1)
ID: 36485932
<I'm sure you could fo this in 2003...>

if you can do this in 2003, just adapt what you did in A2003. But i doubt that you can do this.
0
 
LVL 120

Expert Comment

by:Rey Obrero (Capricorn1)
ID: 36485941
it does not make sense that you will prompt for a value, and set the default value.
might as well use the format i posted above at http:#a36485874 
0
 
LVL 7

Author Comment

by:myhc
ID: 36485943
Sure if I still had my db from back in that job.

Not being rude. But how well do you know access. Just need to know if your word will save me more google time or if your just not sure.
0
 
LVL 44

Expert Comment

by:GRayL
ID: 36485954
WHERE myDate = Nz(MyDate,#2011-09-05#)

given the default you are looking for is the date 2011-09-05, you will be prompted for the parameter MyDate, if you choose not to enter a date and hit ENTER, #2011-09-05# will be provided.  You can use the same approach for your operating system question.  The solution is not to use LIKE but the function Nz().
0
 
LVL 120

Expert Comment

by:Rey Obrero (Capricorn1)
ID: 36485965
yes that will work but you will not see the "default value" in the input box of the prompt.
0
 
LVL 7

Author Comment

by:myhc
ID: 36485975
But the query will bring back some data. I could add a note about the default in the input title.

What is Nz standing for?
0
 
LVL 120

Expert Comment

by:Rey Obrero (Capricorn1)
ID: 36486126
well, i guess i did not fully understandd what you really wanted
0
 
LVL 61

Accepted Solution

by:
mbizup earned 2000 total points
ID: 36486167
You cant do what you are asking through the 'input box' that pops up when running a stored query (ie: all SQL, no Visual basic)

However, CAN build up your criteria by defining you query in Visual Basic code and using the VBA inputbox function, which allows a 'default value':

InputBox("Enter the OS criteria","OS","Windows 7")

That said, if you have many criteria that need to be defined like this, I would suggest steering away from the input boxes, and creating a "filter form", with textboxes, combos, etc for all of the fields that you are allowing as criteria.  Any of these controls can be set up to display a default value.  You would add a button to open the form whose recordsource you are defining with this query.

The code behind that button would be:

Docmd.openform "YourFormName",,,"DateField=#" & me.txtDate & "# AND OperatingSystem = '" & me.txtOS & "' " 

etc.

0
 
LVL 44

Expert Comment

by:GRayL
ID: 36496493
Nz() is a function which replaces a null value with anything you like.  Press Alt+F11 to get to the VB editor and in help type - Nz function.  

On a form, report, as a default value in a table - there are a number of instances where it fits the problem - this appeared to be one of them.
0

Featured Post

Free Tool: Subnet Calculator

The subnet calculator helps you design networks by taking an IP address and network mask and returning information such as network, broadcast address, and host range.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

If you need to forecast numbers -- typically for finance -- the Windows and Mac versions of Excel 2016 have a basket of tools to get the job done.
Explore the ways to Unlock VBA Project Password Excel 2010 & 2013 documents. Go through the article and perform the steps carefully to remove VBA Excel .xls file.
The view will learn how to download and install SIMTOOLS and FORMLIST into Excel, how to use SIMTOOLS to generate a Monte Carlo simulation of 30 sales calls, and how to calculate the conditional probability based on the results of the Monte Carlo …
The viewer will learn how to  create a slide that will launch other presentations in Microsoft PowerPoint. In the finished slide, each item launches a new PowerPoint presentation and when each is finished it automatically comes back to this slide: …

604 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question