Re: date entry validation problem

Tech Tip: Click here to run a free scan for Windows Errors and optimize PC performance





"Dylan Moran" wrote:

> Excellent. Thanks Allen.
>
> --
> I may not know VBA inside out, but from the outside I am looking in.
> Dylan Moran - Melbourne Australia
>
>
> "Allen Browne" wrote:
>
> > Your code indicates that you want to compare 2 values. In Windows, you have
> > no idea if the use will click on a text box (they may never visit it), or in
> > what order they will click on the controls.
> >
> > Therefore, you need to use the BeforeUpdate event of the *form* for
> > validation that involves comparing controls. Cancel the event to prevent the
> > bad data being written.
> >
> > Private Sub Form_BeforeUpdate(Cancel As Integer)
> > If Me.ElecReturnAcknowledgedDate < Me.ElecReturnSubmittedDate Then
> > Cancel = True
> > MsgBox "Your ack...
> > End If
> > End Sub
> >
> > Another other reason the MsgBox will not fire would be if either of the
> > dates were blank.
> >
> > Occassionally, you find that the Properties box is missing the [Event
> > Procedure] on the Events tab, which will also mean the code will not fire.
> >
> > --
> > 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.
> >
> > "Dylan Moran" <DylanMoran@xxxxxxxxxxxxxxxxxxxxxxxxx> wrote in message
> > news:9BB3A633-5011-4DE2-9B77-DCC04F080226@xxxxxxxxxxxxxxxx
> > > This code does not seem to trigger. Any ideas why?
> > > The fields are text feilds formatted dd/mm/yy
> > > I assume this may be my problem.
> > > Any recommendations on how I can get this to work?
> > >
> > >
> > > Private Sub ElecReturnAcknowledgedDate_LostFocus()
> > >
> > > ' Date validation
> > >
> > > If Me.ElecReturnAcknowledgedDate.Value < Me.ElecReturnSubmittedDate.Value
> > > Then
> > > MsgBox "Your acknowledgement date is before the submitted date.", _
> > > vbExclamation, "Unexpected data"
> > > End If
> > >
> > > End Sub
> > >
> > >
> > >
> > > --
> > > I may not know VBA inside out, but from the outside I am looking in.
> > > Dylan Moran - Melbourne Australia
> >
> >
> >
.



Relevant Pages

  • Re: Bias in rand for excel 07
    ... that was statistically different from expectation. ... Sub SimplerVersion() ... "yttrias" wrote: ... There is no RANDfunction in VBA. ...
    (microsoft.public.excel.programming)
  • Re: Bias in rand for excel 07
    ... F1 with a dynamic formula that will update whenever the RAND() functions ... Sub SimplerVersion() ... "yttrias" wrote: ... There is no RANDfunction in VBA. ...
    (microsoft.public.excel.programming)
  • Re: merging documents into templates - automation problem
    ... The code to launch ... Private Sub UserForm_Initialize ... UserForm_Initialize is an EVENT for the UserForm, called by VBA when the ... the code is in a code module for a form. ...
    (microsoft.public.office.developer.automation)
  • RE:reasons as requested
    ... Sub TestThis() ... > im sure i can get vba to do what i want with this function but at the moment ... as a pivot table for this instance would not ... >> first time it is used from the top. ...
    (microsoft.public.excel.programming)
  • Re: Circular dependencies between modules
    ... Public Sub SetData ... MODULE" is set, by VBA, to "yes". ... >> AddedEmpsignals that a new employee has been added ... >> to a new employee in its underlying file ...
    (microsoft.public.access.formscoding)