Kat-
If there are no records in the Expired Permits table (or query) or they all have Null in CityPermit_ExpDate, then that's why your code is ending prematurely.
BTW, you're using Execute to clear the table, so why not use it again to run the Expired Permits Query? That's the preferred method.
John Viescas, Author
Effective SQL
SQL Queries for Mere Mortals
Microsoft Access 2010 Inside Out
Microsoft Access 2007 Inside Out
Microsoft Access 2003 Inside Out
Building Microsoft Access Applications
http://www.viescas.com/
(Paris, France)
On Sep 6, 2016, at 6:33 PM, ka0t1c_ang3l <no_reply@yahoogroups.com> wrote:
Hello!
What I am trying to do is have my database send an email to companies when their permits have expired or will expire. I have a main menu with a button for "permits expiring". The button open the "permits expiring" form which has an unbound text box "txtnotify" and a button with code the following code:
Private Sub Command2_Click()
Dim db As DAO.Database, rst As DAO.Recordset
If IsNull(DLookup("[CityPermit_ExpDate]", "[Expired Permits]")) Then
MsgBox "There are no permits expiring."
DoCmd.Close acForm, Me.Name
Else
' Point to this database
Set db = CurrentDb
' Clean out the working table
CurrentDb.Execute "DELETE * FROM [SEND TBL]", dbFailOnError
' Avoid prompts
DoCmd.SetWarnings False
' Loadin the rows to select
DoCmd.OpenQuery "Expired Permits Query"
'Turn on prompts again
DoCmd.SetWarnings True
' Clear the database object
Set db = Nothing
' Open the selection form
DoCmd.OpenForm "SEND FRM"
' Close me
DoCmd.Close acForm, Me.Name
End If
End Sub
When I enter the number of days in the "permits expiring" form, and click the run button, I am getting the message that there are no permits expiring; however, there are permits expiring. I'm not exactly sure what I'm doing wrong. If needed, I can upload the database.
Your help is greatly appreciated!
Kat
------------------------------------
------------------------------------
------------------------------------
Yahoo Groups Links
Posted by: John Viescas <johnv@msn.com>
Reply via web post | • | Reply to sender | • | Reply to group | • | Start a New Topic | • | Messages in this topic (2) |
Tidak ada komentar:
Posting Komentar