Share via

Adding Notification to Access

Anonymous
2015-09-22T04:02:05+00:00

Hello,

I am new to Access, and I am trying to create a contact list for my professional network. I really like the Contacts Management template available, but would like to add two features that involve notifications. 

  1. A notification when Access opens reminding me of Birthdays. I know the Access form already has a birthday entry field, but I would like to be able to create a notification a few days prior to the birthday, so I can remember to send a birthday card.
  2. I would like to be able to create a "contact on" field or task that allows me to enter a date on which I need to contact this person to just say hello.

Any help would be much appreciated! I am using Access 2013 btw.

Microsoft 365 and Office | Access | For home | Windows

Locked Question. This question was migrated from the Microsoft Support Community. You can vote on whether it's helpful, but you can't add comments or replies or follow the question.

0 comments No comments

4 answers

Sort by: Most helpful
  1. ScottGem 68,810 Reputation points Volunteer Moderator
    2015-09-22T11:18:17+00:00

    For the Birthday notifications, I would create a report that lists upcoming birthdays. First you need a query to do so. Open Query Design mode and select your contacts table. Add the fields you want to include in the report (names, etc.), then add a column with the following expression:

    NextDOB: DateSerial(Year(Date()),Month([DOB]),Day([DOB])) 

    Use the actual name of your DOB field. 

    For the Criteria of that column use:

    BETWEEN Date() AND Date()+30

    This will display all contacts with birthdays coming up in the next 30 days.

    You can then use this query as the Recordsource for your report.

    To display this report when you open your database, create a macro named Autoexec and use the OpenReport action to open that report.

    For the second issue. Open the Contacts table in Design mode and add a field:

    NextContact as a DateTime type

    I don't think you need another table just for this reminder field. But you will need to open your form in Design mode to add a control for the new field.

    Both can be done with almost no need for code (other than to open the report).

    Was this answer helpful?

    3 people found this answer helpful.
    0 comments No comments
  2. Anonymous
    2015-09-22T10:48:52+00:00

    For your first requirement, try the following code in your first / main form opened:

    Option Compare Database

    Option Explicit

    Private Sub Form_Open(Cancel As Integer)

        BirthdayReminder

    End Sub

    Private Sub BirthdayReminder()

        On Error GoTo Err_Process

        Dim rst1 As Recordset

        Dim dbs1 As Database

        Dim strSQL As String

        Dim strContact As String

        strSQL = "SELECT Contact1.Fname, Contact1.Sname, Contact1.DOB" & vbCrLf & _

        "FROM Contact1" & vbCrLf & _

        "WHERE (((DateDiff('d',Date(),DateSerial(Year(Date()),Month([DOB]),Day([DOB]))))=3));"

        Set dbs1 = CurrentDb

        Set rst1 = dbs1.OpenRecordset(strSQL, dbOpenSnapshot)

        With rst1

            Do While Not .EOF

                If (strContact = "") Then

                    strContact = .Fields(0) & " " & .Fields(1) & " DOB: " & .Fields(2)

                Else

                    strContact = strContact & vbCrLf & .Fields(0) & " " & .Fields(1) & " DOB: " & .Fields(2)

                End If

                .MoveNext

            Loop

            .Close

        End With

        If (strContact <> "") Then

            MsgBox "Please send birthday card(s) to the following:" & vbCrLf & strContact, vbInformation, "Birthdays"

        End If

    Exit_Process:

        Set rst1 = Nothing

        Set dbs1 = Nothing

        Exit Sub

    Err_Process:

        MsgBox Error$

        Resume Exit_Process

        Resume 0

    End Sub

    For your second requirement, you will need to create a table called something like ContactReminder:

    You can then create a form based on the table that can either be opened from the contacts form or displayed as a sub form on the contacts form.

    Was this answer helpful?

    1 person found this answer helpful.
    0 comments No comments
  3. Anonymous
    2015-09-22T12:25:35+00:00

    Hey there. Thank you for the first reply. On the first instruction, I'm a bit unsure where this code goes. Any further insight you could provide? Thanks

    When the application initially opens, there is one form that is automatically opened.  It is that form that you want to add the code to.

    Was this answer helpful?

    0 comments No comments
  4. Anonymous
    2015-09-22T12:16:35+00:00

    Hey there. Thank you for the first reply. On the first instruction, I'm a bit unsure where this code goes. Any further insight you could provide? Thanks

    Was this answer helpful?

    0 comments No comments