Solved

criteria

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

Ransomware-A Revenue Bonanza for Service Providers

Ransomware – malware that gets on your customers’ computers, encrypts their data, and extorts a hefty ransom for the decryption keys – is a surging new threat.  The purpose of this eBook is to educate the reader about ransomware attacks.

Question has a verified solution.

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

Introduction The Visual Basic for Applications (VBA) language is at the heart of every application that you write. It is your key to taking Access beyond the world of wizards into a world where anything is possible. This article introduces you to…
It’s been over a month into 2017, and there is already a sophisticated Gmail phishing email making it rounds. New techniques and tactics, have given hackers a way to authentically impersonate your contacts.How it Works The attack works by targeti…
As developers, we are not limited to the functions provided by the VBA language. In addition, we can call the functions that are part of the Windows operating system. These functions are part of the Windows API (Application Programming Interface). U…
Familiarize people with the process of utilizing SQL Server stored procedures from within Microsoft Access. Microsoft Access is a very powerful client/server development tool. One of the SQL Server objects that you can interact with from within Micr…

813 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

10 Experts available now in Live!

Get 1:1 Help Now