Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Enabling form field based on date 2

Status
Not open for further replies.

cfd48

Technical User
Mar 27, 2008
3
US
I have a field on a form that by default in not enabled, I would like to enable it based on the date, I only need the field enabled on 12/25 and 1/1 of any year. There is a date field on the form. Is there a way with an if statement in the date control properties to do this for any year, I guess making the year portion of the date a wildcard.

This is my first post, so I hope it makes sense.

Thanks for any help
 
Try this in the load event:

If (Month(Date()) = 12 AND Day(Date()) = 25) OR (Month(Date()) = 1 AND Day(Date()) = 1) Then
Me.ControlName.Enabled = True
Else
Me.ControlName.Enabled = False
End If

Paul
MS Access MVP 2007/2008
 
pbaldy, thanks for the fast reply. I should have been more clear. I want the control enabled only if the Date field on the form contains either of those dates. Not based on the current date as that may not be what the user is entering.

I think what I need to do is evaluate the contents of the date field as a string and if it meets either condition then enable the other control, Thats where I'm stuck.

Thanks
 
How are ya cfd48 . . .

In [blue]pbaldy's[/blue] code, replace [blue]date()[/blue] with [purple]Me!YourDateTextboxName[/purple] . . .

Calvin.gif
See Ya! . . . . . .

Be sure to see thread181-473997
Also faq181-2886
 
That did it ! Thanks to both of you for your help

 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top