If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below. |
|
|
Thread Tools | Display Modes |
#1
|
|||
|
|||
date controls
Hello,
I have a date field ona form that I'm trying to prevent the user from entering dates in the past. On the AfterUpdate event I wrote the following code as a warning message if they pick a date older than current: Private Sub pkgShip_AfterUpdate() If Me.pkgShip Now() Then MsgBox ("You cannot select a date in the past. Please select another date.") Else End If End Sub However nothing seems to happen if I enter dates in the past. Is this not the way to do it or am I writing this statement incorrectly? Thanks. Al |
#2
|
|||
|
|||
date controls
Use the BeforeUpdate event of the control:
Private Sub pkgShip_BeforeUpdate(Cancel As Integer) If DateValue(Me.pkgShip) Date() Then MsgBox "You cannot select a date in the past. Please select another date.", vbExclamation, "Old Date!" Cancel = True End If End Sub -- Ken Snell MS ACCESS MVP "Alan" wrote in message ... Hello, I have a date field ona form that I'm trying to prevent the user from entering dates in the past. On the AfterUpdate event I wrote the following code as a warning message if they pick a date older than current: Private Sub pkgShip_AfterUpdate() If Me.pkgShip Now() Then MsgBox ("You cannot select a date in the past. Please select another date.") Else End If End Sub However nothing seems to happen if I enter dates in the past. Is this not the way to do it or am I writing this statement incorrectly? Thanks. Al |
#3
|
|||
|
|||
date controls
That worked great!
Thanks! Al "Ken Snell (MVP)" wrote: Use the BeforeUpdate event of the control: Private Sub pkgShip_BeforeUpdate(Cancel As Integer) If DateValue(Me.pkgShip) Date() Then MsgBox "You cannot select a date in the past. Please select another date.", vbExclamation, "Old Date!" Cancel = True End If End Sub -- Ken Snell MS ACCESS MVP "Alan" wrote in message ... Hello, I have a date field ona form that I'm trying to prevent the user from entering dates in the past. On the AfterUpdate event I wrote the following code as a warning message if they pick a date older than current: Private Sub pkgShip_AfterUpdate() If Me.pkgShip Now() Then MsgBox ("You cannot select a date in the past. Please select another date.") Else End If End Sub However nothing seems to happen if I enter dates in the past. Is this not the way to do it or am I writing this statement incorrectly? Thanks. Al |
Thread Tools | |
Display Modes | |
|
|