[Last Call] Learn how to a build a cloud-first strategyRegister Now

x
?
Solved

criteria

Posted on 2002-03-27
5
Medium Priority
?
274 Views
Last Modified: 2008-02-01
when creating a query critieror using the following

Expr1: Year([date])

[Enter year:]

this works great but how can i make the popup box that appears to type the year into already have text in ie the currant year i know that

Year(Date())

displays all my records of the currant year. A combination of the 2 would be great. This would mean that i do not have to type in the currant year every time, but if i wanted to view the previous years records i ccould do that esily

cheers migs
0
Comment
Question by:a_migdal
5 Comments
 
LVL 1

Expert Comment

by:TheNextStep
ID: 6899253
Use a pop-up form with an unbound field on it, and set its defalut value to Year(Date()).  Next set the criteria in your query to forms![TheNameOfYourPopupForm]![TheNameOfYourField].

The query will use the value on the form.  You can change it or leave it as is.  Place a button on the form to execute your query.
0
 
LVL 3

Expert Comment

by:Bob Scriver
ID: 6899559
You could go a step further with with the pop-up form and instead of using a text box you could use a combo box that would have as its RowSource something like the following:

SELECT Year([DateInTable]) AS Expr1
FROM tblYourTable
GROUP BY Year([DateInTable])
ORDER BY Year([DateInTable]) DESC;

The default value for the combo could be Year(Date()) and the criteria in your query could then reference the combobox on the pop-up form.

In the OnLoad event procedure of the popup form enter the following:

me![ComboBoxName].setfocus
me![ComboBoxName].dropdown

This way all years that are possibile in your table are in the drop-down of the combobox.  They are sorted Descending so that the top one is the current one and you will only have to pick the appropriate year that you wish to run.  No typing.

Bob Scriver
0
 
LVL 2

Accepted Solution

by:
kiddiec earned 100 total points
ID: 6903126
Create the following Function in a module

Function WhichYear()
WhichYear = InputBox("Which Year", "Enter Year in Two digit mode", Format(Date, "yy"))

End Function


then call the function from the criteria of the query, as follows

whichyear()

This will put up an input box with the current year as the default.  Of cours, by amending the format of the date you can make it match your data
0
 
LVL 54

Expert Comment

by:nico5038
ID: 7079523
for a_migdal

No comment has been added for the last two months.
So it's time to clean up this TA.
I will leave a recommendation in Community Support that this question is:
 - Answered by: kiddiec  
Please leave any comments here within the
next seven days.

PLEASE DO NOT ACCEPT THIS COMMENT AS AN ANSWER !

Nic;o)
0
 
LVL 1

Expert Comment

by:Moondancer
ID: 7099939
Thanks for your help, Nic;o)
Finalized by Moondancer - EE Moderator
0

Featured Post

Get free NFR key for Veeam Availability Suite 9.5

Veeam is happy to provide a free NFR license (1 year, 2 sockets) to all certified IT Pros. The license allows for the non-production use of Veeam Availability Suite v9.5 in your home lab, without any feature limitations. It works for both VMware and Hyper-V environments

Question has a verified solution.

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

Did you know that more than 4 billion data records have been recorded as lost or stolen since 2013? It was a staggering number brought to our attention during last week’s ManageEngine webinar, where attendees received a comprehensive look at the ma…
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.
Do you want to know how to make a graph with Microsoft Access? First, create a query with the data for the chart. Then make a blank form and add a chart control. This video also shows how to change what data is displayed on the graph as well as form…
Visualize your data even better in Access queries. Given a date and a value, this lesson shows how to compare that value with the previous value, calculate the difference, and display a circle if the value is the same, an up triangle if it increased…
Suggested Courses

829 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