Selasa, 06 September 2016

Re: [MS_AccessPros] Help with form/query



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
(Paris, France)

On Sep 6, 2016, at 6:33 PM, ka0t1c_ang3l <> wrote:


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
' 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!





Yahoo Groups Links


Posted by: John Viescas <>
Reply via web post Reply to sender Reply to group Start a New Topic Messages in this topic (2)

Have you tried the highest rated email app?
With 4.5 stars in iTunes, the Yahoo Mail app is the highest rated email app on the market. What are you waiting for? Now you can access all your inboxes (Gmail, Outlook, AOL and more) in one place. Never delete an email again with 1000GB of free cloud storage.



Tidak ada komentar:

Posting Komentar