473,407 Members | 2,312 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,407 software developers and data experts.

Birthday Remainder VBA...

17
Hi All,
I would like to have a birthday remainder on access form load event VBA...
i have tblEmp with 2 fields,
Name DOB
A 22/04/1977
B 25/03/1965
C 17/08/1985

i would like to compare Date and month with my system date to show in the message box "Mr. A Birthday Today" on the Form load event...
Thanks in advance!!!
Apr 27 '15 #1
5 2265
Luuk
1,047 Expert 1GB
Remainder is what is left over from a mathematical calculation
Reminder is an alarm for a date or a meeting

What id you try to accomplish this?

You do know the function(s): DAY() and MONTH() ?
Apr 27 '15 #2
Hi,

Expand|Select|Wrap|Line Numbers
  1. Public Function fDOBNotices() As Boolean
  2.     Dim db As DAO.Database, rs As DAO.Recordset
  3.     Dim strTo As String, strSubject As String, strBody As String
  4.  
  5.     Set db = CurrentDb()
  6.     Set rs = db.OpenRecordset("DOBNotification")
  7.  
  8.     strTo = "SOME_USER@SOME_SERVER.com"
  9.     strSubject = "Birthday Notification"
  10.     strBody = "This is to inform you that the following people will be celebrating their birthday tomorrow!" & vbNewLine
  11.     If rs.RecordCount <> 0 Then
  12.         Do While Not rs.EOF
  13.             strBody = strBody & rs.Fields("PersonName") & vbNewLine
  14.             rs.MoveNext
  15.         Loop
  16.         DoCmd.SendObject To:= strTo, Subject:= strSubject, MessageText:= strBody, EditMessage:=False
  17.     End If
  18.     Set rs = Nothing
  19.     Set db = Nothing
  20. End Function
May be this code will help you out and let me know the result whether it will work for you or not.
Apr 28 '15 #3
zmbd
5,501 Expert Mod 4TB
Note in Monika's code line 6:
Set rs = db.OpenRecordset("DOBNotification")
Appears to require that query [DOBNotification] be available.
The SQL for this can be hardcoded into the VBA script as well.

Line 8 in Monika's code, I've removed the personal email address. We don't allow personal email addresses to be posted for the protection of our members. Too many spammers and criminals out there. This code could be modified to use a recordset that loops thru a set of email addresses to send the email to a group of people. Build the string in lines 11 thru 15 then use the email recordset looped around line 16.

This code may fail if not using Outlook as the primary email program if it doesn't use the MAPI interface.

Another thing to note, Anbusds is asking for a message to appear on screen during the form_load event, not an email. However, Anbusds does not indicate wither this should be a message box, a list box, show up on the form itself, a modal popup etc... all of the messages can be done by taking the basic loop concept in lines 11 thru 15 in Monika's code. Personally, I would setup a simple list box with the [record source] set to a query (either stored or at form level) that pulls against the DOB equal to today.

Finally, it is very important to note that internally, MSACCESS handles all dates in the #MM/DD/YYYY# format regardless of your local settings.
Allen Browne: International Dates in Access
Apr 28 '15 #4
Anbusds
17
Hi Monika,
Just to inform you previously i have tried this code not working & am using access 2003,
is it the reason?
Have you tried this code?
please let me know if any updates!!!
Thanks...

Anbu
Apr 29 '15 #5
Anbusds
17
Hi Zmbd,
Noted, i have found a solution for message box appears once you open the form, send via email also more useful than just a message box...
let me have your solution for send via email...
*Following code for appear as just message box after you open the form*
Form Code:
Expand|Select|Wrap|Line Numbers
  1. Option Compare Database
  2. Option Explicit
  3.  
  4. Private Sub cmbFind_AfterUpdate()
  5.     ' Find the record that matches the control.
  6.     Dim rs As Object
  7.  
  8.     Set rs = Me.Recordset.Clone
  9.     rs.FindFirst "[PersonID] = " & Str(Nz(Me![cmbFind], 0))
  10.     If Not rs.EOF Then Me.Bookmark = rs.Bookmark
  11. End Sub
  12.  
  13.  
  14. Private Sub Form_Current()
  15.   If DCount("PersonID", "qryBirthdayToday", "PersonID =" & Nz(Me.PersonID, 0)) > 0 Then
  16.     Me.labBirthday.Visible = True
  17. '    MsgBox "It's " & Me.PersonName & "'s Birthday Today"
  18.   Else
  19.     Me.labBirthday.Visible = False
  20.   End If
  21. End Sub
  22.  
  23. Private Sub Form_Open(Cancel As Integer)
  24.   If DCount("PersonID", "qryBirthdayToday") > 0 Then
  25.     DoCmd.OpenForm "frmBirthdaysToday", acNormal
  26.   End If
  27. End Sub
  28.  
  29. Query Design Code:
  30. SELECT tblPersons.PersonID, tblPersons.PersonName, tblPersons.DOB, Day([DOB]) & Month([DOB]) AS DM
  31. FROM tblPersons
  32. WHERE (((Day([DOB]) & Month([DOB]))=Day(Date()) & Month(Date())));
Anbu...
Apr 29 '15 #6

Sign in to post your reply or Sign up for a free account.

Similar topics

51
by: Sandra | last post by:
I was given this problem for extra credit and I am just stuck ! BTW - I am not asking for source code and I am not asking anyone to do my homework as I do want to learn .. I just need a hint or two...
1
by: Claude Alain | last post by:
Hello! We are a small non-profit organisation with about 400 members. We have created a database using Access97 which contains tombstone information on our members, including home adresses and...
2
by: edwin van rutten | last post by:
Hi I have a personal database of all adresses etceteras of personal contacts and want to sort the birthday dates in such a way that I have a chronological list for this years birthdays. The...
7
by: Adrian | last post by:
I hit on this problem converting a VB.NET insurance application to C#. Age next birthday calculated from date of birth is often needed in insurance premium calculations. Originally done using...
5
by: NomoreSpam4Me | last post by:
Hi, i did a search and find the way to get the birthday without the year. My field is yyyy/mm/dd, (birthday). I also have a day field (1 to 31) and a month field. (1 to 12) My problem is: I...
13
kestrel
by: kestrel | last post by:
Sheila and He-Man are twins; Sheila is the OLDER twin. Assume they were born immediately after each other, an infinitesimally small - but nonzero - amount of time apart. During one year in the...
1
by: stilldancin12 | last post by:
Ok so i have to write an application that asks for the users birthday and replies with they day of the week in which he or she is born on, using the java program. This is what I have so far.It gives...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.