Solved

criteria

Posted on 2002-03-27
5
260 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 25 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

What Is Threat Intelligence?

Threat intelligence is often discussed, but rarely understood. Starting with a precise definition, along with clear business goals, is essential.

Join & Write a Comment

It took me quite some time to sort out all the different properties of combo and list boxes available from Visual Basic at run-time. Not that the documentation is lacking: the help pages are quite thorough and well written. The problem was rather wh…
I originally created this report in Crystal Reports 2008 where there is an option to underlay sections. I initially came across the problem in Access Reports where I was unable to run my border lines down through the entire page as I was using the P…
Using Microsoft Access, learn some simple rules for how to construct tables in a relational database. Split up all multi-value fields into single values: Split up fields that belong to other things into separate tables: Make sure that all record…
With Microsoft Access, learn how to start a database in different ways and produce different start-up actions allowing you to use a single database to perform multiple tasks. Specify a start-up form through options: Specify an Autoexec macro: Us…

707 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

Need Help in Real-Time?

Connect with top rated Experts

12 Experts available now in Live!

Get 1:1 Help Now