?
Solved

criteria

Posted on 2002-03-27
5
Medium Priority
?
270 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
[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
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

Enterprise Mobility and BYOD For Dummies

Like “For Dummies” books, you can read this in whatever order you choose and learn about mobility and BYOD; and how to put a competitive mobile infrastructure in place. Developed for SMBs and large enterprises alike, you will find helpful use cases, planning, and implementation.

Question has a verified solution.

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

This article describes two methods for creating a combo box that can be used to add new items to the row source -- one for simple lookup tables, and one for a more complex row source where the new item needs data for several fields.
AutoNumbers should increment automatically, without duplicates.  But sometimes something goes wrong, and the next AutoNumber value is a duplicate.  This article shows how to recover from this problem.
In Microsoft Access, learn different ways of passing a string value within a string argument. Also learn what a “Type Mis-match” error is about.
Polish reports in Access so they look terrific. Take yourself to another level. Equations, Back Color, Alternate Back Color. Write easy VBA Code. Tighten space to use less pages. Launch report from a menu, considering criteria only when it is filled…
Suggested Courses

752 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