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
|
|||
|
|||
Message box for form regarding DOB
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/For...forms/201004/1 |
#2
|
|||
|
|||
Message box for form regarding DOB
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/For...forms/201004/1 |
#3
|
|||
|
|||
Message box for form regarding DOB
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/For...forms/201004/1 |
#4
|
|||
|
|||
Message box for form regarding DOB
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/For...forms/201004/1 . |
#5
|
|||
|
|||
Message box for form regarding DOB
On Thu, 15 Apr 2010 12:09:06 GMT, "SamMexico via AccessMonster.com"
u59312@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] |
#6
|
|||
|
|||
Message box for form regarding DOB
Hi John, thanks for your help - I followed your instructions : added a Yes/No
field to the table, put the code into the Current event and added the big label control. I tested it using a new record with a data just over 2 years ago but nothing seemed to happen - any ideas? Thanks, Sam -- Message posted via AccessMonster.com http://www.accessmonster.com/Uwe/For...forms/201004/1 |
#7
|
|||
|
|||
Message box for form regarding DOB
Sam -
You will want to enter the same code on the BeforeUpdate event of the form, or the AfterUpdate event of the DOB field so the error displays. I would also include an Else clause to set the .visible to false for the cases where the criteria is not met. I don't see any code to turn the warning off if they have been warned already, so you may want to include setting the Yes/No field to Yes whenever you display the warning label. -- Daryl S "SamMexico via AccessMonster.com" wrote: Hi John, thanks for your help - I followed your instructions : added a Yes/No field to the table, put the code into the Current event and added the big label control. I tested it using a new record with a data just over 2 years ago but nothing seemed to happen - any ideas? Thanks, Sam -- Message posted via AccessMonster.com http://www.accessmonster.com/Uwe/For...forms/201004/1 . |
Thread Tools | |
Display Modes | |
|
|