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 4505 PEB 1,418
Recognized Expert Top Contributor
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.
MMcCarthy 14,534
Recognized Expert Moderator MVP
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
Recognized Expert Top Contributor
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
Recognized Expert Top Contributor
In fact the solution can be
IF me![dtpicker9].Value>DateSeri al(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.Un do
Me!dtpicker9.Se tfocus
end if
In fact the solution can be
IF me![dtpicker9].Value>DateSeri al(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.Un do
Me!dtpicker9.Se tfocus
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 change the date (i.e when they click on the dtp), i show a message box that states that changing the date will cause all the current bookings to be lost. Do u wish to continue? If the user selects yes all the datatables are cleared and the date is changed...
|
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 will not set the value of the control and will leave
the checked status of the checkbox to false when a user
selects a new date.
this works fine when using the control on a win2k machine
but if we use it on a win XP box and call
|
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
dtpStartDate.Value.ToString() gives the date in the required UK format!
Any ideas? All system locale settings are set to British/UK settings.
|
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, and then any future arrow key presses start
changing the date. I don't want this to happen - i'd like the arrow keys
to continue navigating around the grid. For the dateTimePicker to become
"active", i'd like the user to, say, have to press...
|
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 have UP/DOWN enabled.
The only 3 references to this control in my code are:
1. in my form load event
datRepairDate.Value = Date.Today
| |
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 the DateTimePicker, since the default is shown. My problem
is, if the user does not choose a value from the DateTimePicker (because
using the default is good enough), then during database update, the date
value is not saved to the database; while if...
|
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 checkbox is focused?
|
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 1/1/1970. I create a project datasource from this and
then drag my class onto my form which binds my property to a
datetimepicker.
However when I set the bindingsource to be an instance of my class at
runtime I get the following exception:
|
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:
public DataTable GetOffersForDate_A(DateTime OfferDate)
{
|
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 Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
|
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 protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
| |
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, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own....
Now, this would greatly impact the work of software developers. The idea...
|
by: isladogs |
last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM).
In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules.
He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms.
Adolph will...
|
by: conductexam |
last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one.
At the time of converting from word file to html my equations which are in the word document file was convert into image.
Globals.ThisAddIn.Application.ActiveDocument.Select();...
|
by: TSSRALBI |
last post by:
Hello
I'm a network technician in training and I need your help.
I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs.
The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols.
I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
|
by: adsilva |
last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
|
by: 6302768590 |
last post by:
Hai team
i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
| |
by: muto222 |
last post by:
How can i add a mobile payment intergratation into php mysql website.
| |