How to create birthday alert/warnings?

behedwin

Active Member
Joined
Dec 10, 2014
Messages
399
With this code i take out the birthday date from a socialnumber (personnummer in sweden)

Code:
Sub GetBirthdayDate()
Application.Echo False
    On Error GoTo PROC_ERR

Dim dat
Dim year
Dim mounth
Dim day
Dim age

year = Left(Form_Profile_Form.txtProfilePersonnummer, 2)
mounth = Mid(Form_Profile_Form.txtProfilePersonnummer, 3, 2)
day = Mid(Form_Profile_Form.txtProfilePersonnummer, 5, 2)
dat = DateSerial(year, mounth, day)
dat = Format(dat, "DD MMMM")

Form_Profile_Form.txtBirthdayDate = " den " & dat


PROC_ERR:
    Application.Echo True
    Exit Sub
Application.Echo True
End Sub

For example the number could be 8305065588
83 = year 1983
05 = month may
06 = day 06 in that month
last 4 digits are irrelevant here...


this code works fine.
i get a date and it works great to print it in the txtBirthdayDate object.


However
Now i want to create an alert/warning

something like this
Code:
if dat = todaysdate then
msgbox "BIRTHDAY BIRTHDAY"
else
end if

how can i do this?

i also want to create an alert/event that warns 10 days, 9 days, 8 days etc before an birthday are comming up.
something like
Code:
if dat = todaysdate -10 or dat = todaysdate -9 or dat = todaysdate -8...... then
msgbox "Soon birthday be ready"
else
end if


anyone able to help me do this?


i work in access 2016
 
Last edited:

Excel Facts

Which lookup functions find a value equal or greater than the lookup value?
MATCH uses -1 to find larger value (lookup table must be sorted ZA). XLOOKUP uses 1 to find values greater and does not need to be sorted.
you can call this when the form loads. (for single record form)
Code:
sub CheckBday()
dim dat as date 
dim iDays as integer


'dat = get users birthdate
dat2 = month(dat) & "\" & day(dat), & "\" & year(date)

iDays = dateDiff("d",dat2,Date())
select case iDays
   case 0
       msgbox "BIRTHDAY TODAY"
   case 1
       msgbox "BIRTHDAY is tomorrow"


   case < 10
       msgbox "BIRTHDAY is in " & iDays & " days"
end select
 
Last edited:
Upvote 0
why declare dat when you have commented it out?
and why is not dat2 declared.... shouldent there be something like "dat2 as date"?
 
Upvote 0
i didnt do the grunt work.
declare your variables.
and i didnt know the exact assignment to dat=....
 
Last edited:
Upvote 0

Forum statistics

Threads
1,214,619
Messages
6,120,550
Members
448,970
Latest member
kennimack

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top