Birthday Popup Box

darryaz

Registered User.
Local time
Today, 09:40
Joined
Nov 3, 2011
Messages
13
I can't quite get the VB code to work right on this.....

I have a form that has information about people.

The form stores the person's birthdate (formatted as short date).

If today is the person's birthday I want a MsgBox to come up saying "Happy Birthday" and after the user clicks "OK" SetFocus on the FName field.

Any help would be appreciated.
 
Last edited:
Just think about this: a number of users will find such a feature cute, a number will find it annoying, and the remainder will not care one way or the other. They may be exposed to such "cute" messages in many applications they touch that day, because in each case a developer thought it would be a "cute" feature.

Do you really want to do this?
 
It's to be consistent with another software package that has that function.
 
Or else the users will go on strike? :D

What is the specific issue you are having?
 
For example, if a user is on the phone with a potential donor and is reminded that it is the person's birthday, the user can score a few points with the donor (hopefully) by recognizing it's their birthday.

Here's what I've been trying and it gets an error:
Private Sub Form_Load()
If Me.Birthdate(mmdd) = Date Then MsgBox "Happy Birthday", vbOKOnly, Birthday, , Me.FName.SetFocus Else Me.FName.SetFocus
End Sub
 
and what is Me.Birthdate(mmdd) ? I think Access will object to a field/control name containing ()
 
Basically:
Code:
If DateDiff("d", Me.[COLOR=Red]BirthDay[/COLOR], Date()) = 0 Then
    Msgbox ...
    ... set focus code here ...
End If
 
Just think about this: a number of users will find such a feature cute, a number will find it annoying, and the remainder will not care one way or the other. They may be exposed to such "cute" messages in many applications they touch that day, because in each case a developer thought it would be a "cute" feature.
I would go bunkers :mad: A birthday wish in person or a personalised message is much nicer :D
 
Basically:
Code:
If DateDiff("d", Me.[COLOR=Red]BirthDay[/COLOR], Date()) = 0 Then
    Msgbox ...
    ... set focus code here ...
End If

Thanks vbaInet, that gets me closer, but the field is BirthDATE, so with your code it only works if their birthdate is in 2011.

I'm guessing the DateDiff coding needs to be a bit different to calculate from the birthdate.
 
so with your code it only works if their birthdate is in 2011.
The chances of a newly born baby using a database is very slim :)
Code:
If Format(Me.BirthDate, "ddmm") = Format(Date(), "ddmm") Then
 
That did it.

Exactly what I needed.

Thanks so much!!
 

Users who are viewing this thread

Back
Top Bottom