DTPicker Validation

tabby126

New Member
Joined
Jul 2, 2018
Messages
5
ok so ive been using VBA excel for college work and we need to add a date picker tool to select a date however we need to validate it so that they cant select past dates this is what ive tried but its came up error can anyone help?


If DTPicker1 = < date then
MsgBox "You can not select a past date"
ValidateInput = false
Exit function
End if

please help me out here i really donno what im doing wrong
 

Excel Facts

Highlight Duplicates
Home, Conditional Formatting, Highlight Cells, Duplicate records, OK to add pink formatting to any duplicates in selected range.
ahh ok ..

do you have a variable for date?

if so ... change the name to checkdate for now then on that line also change Date to checkdate

If DTPicker1.Value <= checkdate then

it could be since Date is a reserved word in VBA its throwing it off
 
Upvote 0
ahh ok ..

do you have a variable for date?

if so ... change the name to checkdate for now then on that line also change Date to checkdate

If DTPicker1.Value <= checkdate then

it could be since Date is a reserved word in VBA its throwing it off


Public collection_date As Date - i have that in my modules and that line is coming up the same error
 
Upvote 0
Ok cool so try this
If DTPicker.Value <= collection_date Then


ok so with that it just wont proceed with right or wrong date like its acting as if frozen but thats it i can use all other functions

this has been the best help so far
 
Upvote 0
Based on the image you posted it seems you have a problem with references.

Goto Tools>References...

If there is anything marked as MISSING note it's name and then uncheck it.

Once that's done save and close the workbook, then re-open the workbook and try the code again.
 
Upvote 0

Forum statistics

Threads
1,223,898
Messages
6,175,272
Members
452,628
Latest member
dd2

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top