PC Review


Reply
Thread Tools Rate Thread

Allan Browne Calendar question

 
 
deb
Guest
Posts: n/a
 
      8th Jul 2008

I am using Allan Browne's calendar and it works great!!
I have a form with ProjStart and ProjEnd, both are date fields using the
calendar.

I need to make sure the ProjEnd is not before ProjStart.
I tried...
Private Sub ProjStart_AfterUpdate()
If Me.ProjStart> Me.ProjEnd Then
MsgBox "ProjEnd cannot be before ProjStart"
Me.ProjStart.Undo
End If
End Sub
But it only works if the date is typed in, and not when using the calendar
control.

The calendar is triggered by the OnClick event using,
=CalendarFor([ProjStart],"Set Project Start date")

Please help,

--
deb
 
Reply With Quote
 
 
 
 
Allen Browne
Guest
Posts: n/a
 
      8th Jul 2008
Assuming this is a bound form, use the BeforeUpdate event procedure of the
*form* to verify that the end date is after the start date. That's always
the best approach for comparing 2 dates, becuase you don't know which order
the user will enter them.

Private Sub Form_BeforeUpdate(Cancel as Integer)
If Me.ProjEnd < Me.ProjStart Then
Cancel = True
MsgBox "Cannot end before it starts."
End If
End Sub

--
Allen Browne - Microsoft MVP. Perth, Western Australia
Tips for Access users - http://allenbrowne.com/tips.html
Reply to group, rather than allenbrowne at mvps dot org.

"deb" <(E-Mail Removed)> wrote in message
news:AD0E7A25-7891-4228-821A-(E-Mail Removed)...
>
> I am using Allan Browne's calendar and it works great!!
> I have a form with ProjStart and ProjEnd, both are date fields using the
> calendar.
>
> I need to make sure the ProjEnd is not before ProjStart.
> I tried...
> Private Sub ProjStart_AfterUpdate()
> If Me.ProjStart> Me.ProjEnd Then
> MsgBox "ProjEnd cannot be before ProjStart"
> Me.ProjStart.Undo
> End If
> End Sub
> But it only works if the date is typed in, and not when using the calendar
> control.
>
> The calendar is triggered by the OnClick event using,
> =CalendarFor([ProjStart],"Set Project Start date")
>
> Please help,
>
> --
> deb


 
Reply With Quote
Reply

Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Allen Browne Calendar Jim L. Microsoft Access 5 10th Jul 2009 05:39 PM
Allen Browne's Calendar PPCO Microsoft Access 1 17th Jun 2009 02:39 AM
Allen Browne Calendar Question channell Microsoft Access 2 6th Jan 2009 02:43 PM
Allan Browne's calendar Chris Microsoft Access 3 12th Nov 2008 07:30 PM
Allen Browne Popup Calendar - Calendar Button Problem =?Utf-8?B?Sm9hbk9D?= Microsoft Access 6 7th Feb 2006 12:48 AM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 08:20 AM.