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 bkrike on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

If date on form < Now(+7) ???

Status
Not open for further replies.

pookie62

Technical User
Oct 22, 2004
139
GB
Hi,
I want to disable editing certain fields on a form if the date on this form (goes over a year) is smaller then now() + days
How do I write that ???
Now I have this, but I need those extra 7 days on top of the present datefield[txtDatumFix]

If Forms![Inschrijving].[txtDatumFix] < Now() Then
Me.AllowEdits = False
Me.AllowAdditions = False
End If

Thanks for helping out..
 


Hi,

The Now() function includes TIME. The Date() function returns the current date
Code:
If Forms![Inschrijving].[txtDatumFix] < Date()+ 7 Then
caveat: Forms![Inschrijving].[txtDatumFix] must be a REAL MS Date

So if it's NOT...
Code:
If Forms![Inschrijving].[txtDatumFix] < Format(Date()+ 7 ,"yyyy=mm-dd") Then
assuming that the text string representing the date has been entered yyyy-mm-dd, dashed 'n all.

Skip,

[glasses] [red]A palindrome gone wrong?[/red]
A man, a plan, a ROOT canal...
PULLEMALL![tongue]
 
Thanks for your reply skip,
Changed the code to this:
Code:
If Forms![Inschrijving].[txtDatumFix] < Format(Date + 7, "dd-mm-yyyy") Then
Prob no wis that even futured dates forms, (it's a db with matches in it already scheduled for this year) I can't edit anything..
I need to be able to edit in those future events ofcourse, but would like to block score editting (behind a button).
With this code:
Code:
 If Forms![Inschrijving].[txtDatumFix] < Now() Then
I could edit the future dated forms..
Since this db is spread over the country, I want to give the organising club a week extra time to enter all the match data in the db.
Hope I explained better now.. ?
 
Anyone ??
Please.. need this functionality very hard..
Thanks
 

What is the question?

Skip,

[glasses] [red]A palindrome gone wrong?[/red]
A man, a plan, a ROOT canal...
PULLEMALL![tongue]
 
Why not simply this ?
If Forms!Inschrijving!txtDatumFix < Now() - 7 Then

Hope This Helps, PH.
Want to get great answers to your Tek-Tips questions? Have a look at FAQ219-2884 or FAQ181-2886
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top