473,403 Members | 2,284 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,403 software developers and data experts.

Force Current Year

64
Good morning.

I am running a timecard program in Access 2007 and it seems that the users have trouble entering the correct year when entering the date in the date field. Date field entry format is mm/dd/yy and is displayed as mm/dd/yyyy.

How can I force the current year to be entered?

Thanks

TomB
Jan 15 '09 #1
5 1945
FishVal
2,653 Expert 2GB
Hello, Tom.

Try to reconstruct date entered by user with DateSerial() function.
Day() and Month() functions will help you to extract correspondent values from user input while Year(Date()) will give you current year.

Regards,
Fish.
Jan 15 '09 #2
MindBender77
234 100+
@tbeers
My first question is what type of control is the date field in ie. Textbox?

Second, why do you need to have them enter this manually. You could simply have the control source of the textbox =Date(). Which will produce the current date automatically.

Bender
Jan 15 '09 #3
tbeers
64
I have the textbox = date() set, but sometimes they enter time for different days other than the current day. I just want an alert or procedure that keeps any year other than current year from being entered.

-Thanks

-Tom
Jan 15 '09 #4
ChipR
1,287 Expert 1GB
In the text box's validation rule put:

Format([text0],"yy")=Format(Date(),"yy")
Jan 15 '09 #5
MindBender77
234 100+
@tbeers
You could set the enable property of the textbox to "false" which should prevent users from changing anything you don't want them to change. It will just gray out the textbox but, retain the data.

Or something like this in OnExit event of your textbox:
Expand|Select|Wrap|Line Numbers
  1. If format(" & Textbox1 & ", "yy")  <> format(Date,"yy") Then
  2. msgbox("Please Enter the Current year.")
  3. docmd.cancelevent
  4. textbox1.setfocus
  5. else
  6. 'do something here.........
  7. end if
  8.  
Note, this is untested.

HTH,
Bender
Jan 15 '09 #6

Sign in to post your reply or Sign up for a free account.

Similar topics

3
by: Nige | last post by:
I'm not sure if this is the right group, but I thought the solution may be JS related, hence my post. I've got a web site that is frequently updated; yesterday several subscribers contacted me...
4
by: Dave | last post by:
Hi, Can anyone tell me a simple way of inserting some sort of code into a Dreamweaver template (it goes at the bottom of the page in Copyright info) that will cause the current year to be...
4
by: Jason Chan | last post by:
How can I get the month and year a calendar control current displaying? My problem is I want to load a list of event to a calendar so that it display difference style if there a event for a day....
3
by: jannoergaard | last post by:
Hi I want to write a function that can return a sum for a given date range. The same function should be able to return the sum for the same period year before. Let me give an example: The...
2
by: rpboll | last post by:
Is there a function that stamps the FISCAL Date (Starting from October)? I am trying to generate a Fiscal Date and an AutoNumber for a key field. Thanks for any suggestions. RBollinger
5
by: Jimmy | last post by:
How do I set the default value of a text box (date/time) to 1/1/Current Year... i.e 1/1/2006 this year, 1/1/2007 next year?
5
by: bruce24444 | last post by:
I have a database which assigns warranty claims to people with a main screen showing number of files assigned to each person. The number assigned shows day, week, month and year numbers so they can...
3
by: Johan Mcgillicutty | last post by:
Could use some help on this one- I’m new to MS Access, and even newer to SQL. I’m building a database for clients of a treatment center, and need to keep track of when people are due for their...
5
by: Aljosa Mohorovic | last post by:
i use this to find out current week and total number of weeks for current year: now = datetime.now() weeks_in_year = int(date(now.year, 12, 31).strftime("%W")) current_week = int(date(now.year,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.