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

Working with dates

Status
Not open for further replies.

jdgreen

Technical User
Mar 21, 2001
144
US
I have a form that doesn't allow the user to print a label if the data for the label has not been updated/verified in the last two days. It is a simple If/Then statement based on a date/time stamp field. I have been asked to change this to they can't print if it has not been updated each Wednesday. In other words, if it is Thursday and the info has not been updated since the previous Wed, they can't print. I have never worked with days of the week and can't get a grip on this one. Here is what I am currently using(so simple):
If Me.Date.Value = Now() Then
Me.Command72.Enabled = True
ElseIf Me.Date.Value > Now() - 2 Then
Me.Command72.Enabled = True
Else
Me.Command72.Enabled = False
End If

Thanks

John Green
 



Hi,
Code:
If Me.Date.Value >= Date() - 2 Then
        Me.Command72.Enabled = True
    Else
        Me.Command72.Enabled = False
    End If


Skip,
[sub]
[glasses]Just traded in my old subtlety...
for a NUANCE![tongue][/sub]
 
This code should be in the On Current and/or After Update event of the form.

IMO, don't name fields or controls with names of functions (Date is a function name). Also you should consider giving your command buttons a decent, descriptive name. You should be able to identify the purpose of a control by just reading the code. I would probably code like the following
Code:
   Me.cmdPrintLabel.Enabled = (Me.txtVerifyDate >= Date() - 2)

Duane
Hook'D on Access
MS Access MVP
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top