From: SamMexico via AccessMonster.com on
Hi everyone,

I have gotten a bit stuck trying to set up a message box that opens if the
form record shows the date of birth as over 2 years old. Ideally when any
record is opened and the DOB has been entered the message box should appear
warning the user (but not if the text box is empty). There should also be a
button to deactivate the warning box for each individual record.

The form itself has a 'DOB' text box field but no age specifications.

If anyone could help me out I would be really grateful

Sam

--
Message posted via AccessMonster.com
http://www.accessmonster.com/Uwe/Forums.aspx/access-forms/201004/1

From: SamMexico via AccessMonster.com on
Sorry - just to clarify; when a person reaches 2 years old I would like the
message box to warn the user....

Cheers,

Sam

--
Message posted via AccessMonster.com
http://www.accessmonster.com/Uwe/Forums.aspx/access-forms/201004/1

From: SamMexico via AccessMonster.com on
but also to have a cut off point when the person is over 16 years of age -
the limitations just keep getting bigger...:)

--
Message posted via AccessMonster.com
http://www.accessmonster.com/Uwe/Forums.aspx/access-forms/201004/1

From: Daryl S on
Sam -

For a button to deactivate the warning, that would need to be bound to a
field in the table so that this could be 'remembered'. A checkbox would be
better than a button for this. Assuming you have added the 'ignoreWarning'
field and the appropriate checkbox on the form, then you can add code to
display a message only if the DOB is more than two but less than 16 years ago:

If not me.IgnoreWarning Then
If (DateAdd("yyyy",2,nz(Me.DOB,0)) > Date()) AND
(DateAdd("yyyy",16,nz(Me.DOB,Date())) < Date()) Then
msgbox("DOB is over 2 years ago")
End If
End If

This code would be in the AfterUpdate event of the DOB field if you want the
message to come up when the DOB is changed (as long as the IngoreWarning was
false).
This code would be in the OnCurrent event of the form if you want the
message to come up when a user moves to this record.

That should get you started...

--
Daryl S


"SamMexico via AccessMonster.com" wrote:

> but also to have a cut off point when the person is over 16 years of age -
> the limitations just keep getting bigger...:)
>
> --
> Message posted via AccessMonster.com
> http://www.accessmonster.com/Uwe/Forums.aspx/access-forms/201004/1
>
> .
>
From: John W. Vinson on
On Thu, 15 Apr 2010 12:09:06 GMT, "SamMexico via AccessMonster.com"
<u59312(a)uwe> wrote:

>Hi everyone,
>
>I have gotten a bit stuck trying to set up a message box that opens if the
>form record shows the date of birth as over 2 years old. Ideally when any
>record is opened and the DOB has been entered the message box should appear
>warning the user (but not if the text box is empty). There should also be a
>button to deactivate the warning box for each individual record.
>
>The form itself has a 'DOB' text box field but no age specifications.
>
>If anyone could help me out I would be really grateful
>
>Sam

I'd suggest adding a Yes/No field HasBeenWarned to the table (otherwise you
won't be able to remember that a warning has been cancelled for this record).

You can then put code in the form's Current event to display the warning. This
can be done several ways, some more intrusive than others. Simplest would be
to just have a big Label control with a caption expressing the warning; have
the label be invisible, and put code in the current event such as

Private Sub Form_Current()
Me!lblWarning.Visible = False ' hide warning by default
If (Not Me!HasBeenWarned) And Not IsNull(Me!DOB) Then
If DateAdd("yyyy", 2, [DOB]) > Date() _
OR DateAdd("yyyy", 16, [DOB]) < Date() Then
Me!lblWarning.Visible = True
End If
End Sub

You can also use MsgBox to pop up a warning message, or take some other
appropriate action.
--

John W. Vinson [MVP]