Is there anyway to change the max date to
datenow + 2 years
I tried this in the properties -> Format -> MaxDate = dateadd("yyyy",2,date())
without success :(
Can anyone help.
Thanks, a big thank you to all those who've helped me previously too :)
9 4479 PEB 1,418
Expert 1GB
Hi
U can use
DateSerial(year(Now())+2, DatePart("m", Now()), Day(Now()))
HI,
Thanks for the reply.
I think the problem is that I need VBA code to allow me to change the parameter of the DateTimepicker as you cant enter argumetns directly into the property maxdate :( then attach it to an event on the form load.
No idea how to go about it though.
HI,
Thanks for the reply.
I think the problem is that I need VBA code to allow me to change the parameter of the DateTimepicker as you cant enter argumetns directly into the property maxdate :( then attach it to an event on the form load.
No idea how to go about it though.
You are trying to put something into format that is actually a validation rule.
You are trying to put something into format that is actually a validation rule.
Thanks, I was thinking that from the error message.
Can I set a limit then using VBA code?
Its an activex control my knowledge about these and VBA you could put on a postage stamp!
PEB 1,418
Expert 1GB
So u can put this vba code in BeforeUpdate Event in the respective Date Field: -
IF me![MyDate].Value>DateSerial(year(Now())+2, DatePart("m", Now()), Day(Now())) then
-
Msgbox "Your date should be less than " +str(DateSerial(year(Now())+2, DatePart("m", Now()), Day(Now())))
-
Update=False
-
end if
-
Much appreciated , the msgbox appears but what the command to set the focus again in the date field (dtpicker9) as at the moment you can click on another field.
Thanks :)
PEB 1,418
Expert 1GB
In fact the solution can be
IF me![dtpicker9].Value>DateSerial(year(Now())+2, DatePart("m", Now()), Day(Now())) then
Msgbox "Your date should be less than " +str(DateSerial(year(Now())+2, DatePart("m", Now()), Day(Now())))
Updated=False
Me!dtpicker9.Undo
Me!dtpicker9.Setfocus
end if
In fact the solution can be
IF me![dtpicker9].Value>DateSerial(year(Now())+2, DatePart("m", Now()), Day(Now())) then
Msgbox "Your date should be less than " +str(DateSerial(year(Now())+2, DatePart("m", Now()), Day(Now())))
Updated=False
Me!dtpicker9.Undo
Me!dtpicker9.Setfocus
end if
I cant understand why as It end the IF condition and displays the message box but it doesnt leave the focus on the dtpicker. Doesnt complain about it but doesnt set focus.
Also had to remove the Undo as isnt an option with the version of access I have.
I should have re-read that before posting!
What I wanted to say is the message box appears but setfocus doesnt appear to function for datetimepicker.
Doesnt complain about syntax or error either.
The undo however is a recognised command so had to remove it.
Thanks for your help :)
Sign in to post your reply or Sign up for a free account.
Similar topics
by: Bhavna |
last post by:
I have a datetimepicker (dtp) on my windows form
the user initially selects a date and then selects the rooms they wish to book
The problem i have is that when the user goes back and tries to...
|
by: Guy |
last post by:
I have extended the datetimepicker control to incorporate
a ReadOnly property.
I have used the new keyword to implement my own version
of the value property, so that if readonly == true then
it...
|
by: Ed Crowley |
last post by:
I have a DateTimePicker control on my form that is displaying the date
format in UK format (dd/mm/yy).
However, in my code dtpStartDate.Value gives a date in US format, but...
|
by: ROG |
last post by:
Hi all
with help from postings on the web, i have a dateTimePicker in one of my
columns in the datagrid.
However, when i move in to this column using the arrow keys, it
automatically pops up,...
|
by: Steve Cutting |
last post by:
Hi all,
I have created a form used for entry of repair details into a table on a
MSDE database. I am using a datetimepicker for entry of the repair date. It
is set to SHORT display format and I...
|
by: Clamara |
last post by:
When adding a new record from my form, I pre-set my DateTimePicker's value to
System.DateTime.Today
Since the "Today" value is used most of the time, the user doesn't need to
select a date from...
|
by: Charlie |
last post by:
In the top portion of the DateTimePicker, where the value of the date is
displayed, how can I detect whether the month or day or year is currently
focused, or, if ShowCheckBox = True, whether the...
|
by: Kevin |
last post by:
I have put a VS2005 sample project up here:
http://www.kevinandkiran.com/CSharpApplication.zip (its only 50k)
Basically I have a class that contains a date property, which is
initialised to...
|
by: Mike |
last post by:
Hi,
I use MS SQL Express and VS 2005 c#, win application.
I would like to select value rom DateTimePicker and list all values
for selected date within GridView.
I have method as follows:
...
|
by: emmanuelkatto |
last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud.
Please let me know.
Thanks!
Emmanuel
|
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...
|
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...
|
by: Hystou |
last post by:
There are some requirements for setting up RAID:
1. The motherboard and BIOS support RAID configuration.
2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
|
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,...
|
by: Hystou |
last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
|
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...
|
by: Hystou |
last post by:
Overview:
Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
|
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...
| |