Below is a bit of code from the basMail module from the Access Cookbook, 2nd Ed (example 10-04, I think). I'm using Access 2k, and I can't get it to work right. I'm opening frmReceiveMail with and AutoExec macro at startup of my database. The form is not re-opening from minimized when new messages are available - not showing "New Mail!" caption either. Any ideas?
P.S. I've enabled DAO references already.
P.S. I've enabled DAO references already.
Code:
Function acbCheckMail() As Integer
' Check for new mail, and if there is any,
' restore the received mail form
On Error GoTo HandleErr
Dim rstClone As DAO.Recordset
Dim frmMail As Form
Set frmMail = Forms("frmReceiveMail")
frmMail.Requery
Set rstClone = frmMail.RecordsetClone
If Not rstClone.EOF Then
rstClone.MoveFirst
frmMail.Caption = "New Mail!"
If IsIconic(frmMail.Hwnd) Then
frmMail.SetFocus
DoCmd.Restore
End If
Else
frmMail.Caption = "No mail"
End If
ExitHere:
Exit Function
HandleErr:
Select Case Err.Number
Case 3021 ' no current record, do nothing
Case Else
MsgBox Err & ": " & Err.Description, , "acbCheckMail()"
End Select
Resume ExitHere
End Function