Is there anyway with vb code to send a popup message to my desktop to
inform me of a soon to be birthday without having opened my database.
It's easy in VBS:
' ***** start of script *****
Option Explicit
' VBS Script to look up upcoming birthday
Const pathMDBFile = "c:\temp\birthdays.mdb"
Const qdfBirthdaysDue = "BirthdaysDue"
' dao constants
Const dbOpenSnapshot = 4
Const dbForwardOnly = 8
Dim dbe, db, ss ' as DBEngine, as Database, as Recordset
Dim displayText ' as string
' create a db engine
Set dbe = CreateObject("DAO.DBEngine.36")
' open the database readonly
Set db = dbe.OpenDatabase(pathMDBFile, False, True)
' get a snapshot of the data
set ss = db.OpenRecordset(qdfBirthdaysDue, dbOpenSnapshot, dbForwardOnly)
' run through any records that may have been returned
Do While Not ss.EOF
' create a simple string, just concatenate the names
' blank lines are ugly
If Len(displayText)>0 Then displayText = displayText + vbNewLine
displayText = displayText & ss.Fields(0).Value
' next record
ss.MoveNext
Loop
' an empty MsgBox is so unhelpful: use some default text instead!
If Len(displayText) = 0 Then displayText = "No birthdays due"
' tell the user
WScript.Echo displayText
' arrange for a neat closedown
ss.Close
db.Close
' ***** End of script *****
If you save the script to a .vbs file, then you can place a link to it in
your Programs/ StartUp menu and it will display every time you start your
PC. An alternative would be to use the Task Scheduler.
By the way, the text of the "BirthdaysDue" query is as follows:
SELECT FName & " " & LName AS FullName
FROM People
WHERE DATESERIAL(
YEAR(DATE()) + IIF(
DATESERIAL(YEAR(DATE()),MONTH(BirthDt),DAY(BirthDt))>=DATE(),0,1),
MONTH(BirthDt),
DAY(BirthDt)
) - DATE() < 21
ORDER BY DATESERIAL(
YEAR(DATE()) + IIF(
DATESERIAL(YEAR(DATE()),MONTH(BirthDt),DAY(BirthDt))>=DATE(),0,1),
MONTH(BirthDt),
DAY(BirthDt));
It just calculates the date of the next birthday given a date of birth in
the field BirthDt, and selects those where it is less than 21 days away.
Hope that helps
Tim F