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

Date related msg.

Status
Not open for further replies.

rickm4

MIS
Sep 7, 2000
15
US
I have a Projects Database that includes a field containes, Estimated Completion Date. I would like to have a pop up msg. appear if the Estimated Completion date (of the project) is = or > than current date. My code i am using now is as follows:
Private sub completion date before update(cancel as interger)
if me![completion date] => date then
me!msgbox[This project is OVERDUE]
end if
end sub

When ii compile the above, It keeps balking at the date portion, the word date is highlighted and it won't go further. I am new to the Module portion of Access so i am sure it will be something silly. Thanks [sig][/sig]
 
Hi Rick,

there appears to be a few errors in syntax, im not sure i follow the logic shouldn't it be if the completion date is less than or equal to Date,...? if completion date is before or equal to todays date. in any case the < or > should be before the = sign

If Me.[completion date] <= Date Then
MsgBox &quot;This project is OVERDUE&quot;
End If

now a hint on naming conventions if you have spaces in your field names and controls you have to use [ ] to contain them when you refer to them in code a real pain! however if you change them to something like
CompletionDate then you can do this

if me.CompletionDate <= date then
msgbox &quot;whatever etc&quot;
end if

also if the [Completion date] is a field on the main form you could also this portion of the code in the forms on current event that way the date will be checked when ever the user goes to a record.

if not (isnull([completion date]) or [completion date] = &quot;&quot;) then

if me.CompletionDate <= date then
msgbox &quot;whatever etc&quot;
end if

end if

the check for is null is to prevent checking if the field empty like a new entry etc. ;-)

HTH
Robert


[sig][/sig]
 
Robert,
I appreciate the response, I am new to the VB portion of Access and learning very slowly. I will try what you have suggested, i am sure that is the answer to the problem. THANKS Rick [sig][/sig]
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top