Rabu, 05 Februari 2014

RE: [MS_AccessPros] AutoExec or something else?

 

This thread has me concerned.  I do believe I use form load, open, and close to run multiple queries and have every reason to believe that they actually HAVE been working, but now I’m a little worried.

 

From: MS_Access_Professionals@yahoogroups.com [mailto:MS_Access_Professionals@yahoogroups.com] On Behalf Of Glenn Lloyd
Sent: Wednesday, February 05, 2014 9:06 AM
To: MS_Access_Professionals@yahoogroups.com
Subject: RE: [MS_AccessPros] AutoExec or something else?

 




Jim,

 

If you use the code John suggested, you also will not need to fiddle with SetWarnings. You can delete both of those DoCmd statements.

 

Glenn

 

From: MS_Access_Professionals@yahoogroups.com [mailto:MS_Access_Professionals@yahoogroups.com] On Behalf Of John Viescas
Sent: Wednesday, February 5, 2014 11:00 AM
To: MS_Access_Professionals@yahoogroups.com
Subject: Re: [MS_AccessPros] AutoExec or something else?

 

 

Jim-

 

Don’t use OpenQuery.  Use:

 

Dim db As DAO.Database

 

    Set db = CurrentDb

    db.Execute “first query”, dbFailOnError

    db.Execute “second query”, dbFailOnError

 

John Viescas, Author

Microsoft Access 2010 Inside Out

Microsoft Access 2007 Inside Out

Microsoft Access 2003 Inside Out

Building Microsoft Access Applications 

SQL Queries for Mere Mortals 

(Paris, France)

 

 

 

On Feb 5, 2014, at 4:45 PM, Jim Wagner <luvmymelody@yahoo.com> wrote:

 

John,

 

I put the code in the On Open event and only the first query ran. The second query did not run. If I put the code behind a button on the form, both queries run. I added msgbox's to see if it gets past the 1st and second queries but the second msgbox never appears.  Below is my code. 

 

Private Sub Form_Open(Cancel As Integer)

' Enable error handler.

    On Error GoTo Error_ErrorHandler

        DoCmd.SetWarnings False

     DoCmd.OpenQuery "qryDeleteAllFromSupervisorTable"     'Deletes all records in the supervisortable

 

        MsgBox "Hi"

        DoCmd.OpenQuery "qryAppendSupervisorTable"            'Appends all records from the tblSourcetblSupervisorList table

        MsgBox "Hi"

        DoCmd.SetWarnings True

 

Exit_ErrorHandler:

    Exit Sub

 

Error_ErrorHandler:

    Resume Exit_ErrorHandler

 

End Sub

 

 

 

Jim Wagner


 

On Wednesday, February 5, 2014 8:41 AM, John Viescas <JohnV@msn.com> wrote:

 

Jim-

 

AutoExec macro or put code to run the queries in the Load event of the form that you open at startup.

 

John Viescas, Author

Microsoft Access 2010 Inside Out

Microsoft Access 2007 Inside Out

Microsoft Access 2003 Inside Out

Building Microsoft Access Applications 

SQL Queries for Mere Mortals 

(Paris, France)

 

 

 

On Feb 5, 2014, at 4:00 PM, Jim Wagner <luvmymelody@yahoo.com> wrote:

 

Hello all,

 

How do I have 2 queries run each time the database is opened. Do I have to use an AutoExec macro or is there another way of programming it?

 

Thank You

 

Jim Wagner


 

 

 

 






This email (and all attachments) is for the sole use of the intended recipient(s) and may contain privileged and/or proprietary information. Any unauthorized review, use, disclosure or distribution is prohibited. If you are not the intended recipient, please contact the sender by reply e-mail and destroy all copies of the original message.

__._,_.___
Reply via web post Reply to sender Reply to group Start a New Topic Messages in this topic (6)
.

__,_._,___

Tidak ada komentar:

Posting Komentar