Wrox Home  
Search P2P Archive for: Go

  Return to Index  

access thread: Using containers to run certain queries


Message #1 by "Eddie Schott" <eddie@p...> on Tue, 8 May 2001 14:37:06 -0700
Thanks to all who answered my delete all records question. I feel a bit

foolish for not thinking of the umm....er.....DELETE!!!!! query.



But now, I think I have a more advanced

question...



I have used the following code

(attached to the click event of a

command button) for running

all queries in an Access 97 database.



Private Sub cmdRunQueries_Click()

On Error GoTo Err_cmdRunQueries_Click



    Dim db As Database

    Dim qdf As QueryDef

    Set db = CurrentDb()

    db.QueryDefs.Refresh





    DoCmd.Hourglass True

    For Each qdf In db.QueryDefs

        qdf.Execute

    Next qdf

    DoCmd.Hourglass False



Exit_cmdRunQueries_Click:

    Exit Sub



Err_cmdRunQueries_Click:

    MsgBox Err.Description

    Resume Exit_cmdRunQueries_Click



End Sub



Now I would like to modify the code to run only queries that begin with

"qdel". I'm having a hard time figuring out what the syntax for exposing the

query name so that I can insert my IF THEN statement.



Can anyone help or give direction to the answers?



--

Eddie Schott

Progressive Action Network









Message #2 by "Pardee, Roy E" <roy.e.pardee@l...> on Tue, 08 May 2001 14:49:10 -0700
Ooh--easy one!  Your qdf looping variable will have a .Name property inside

the For Each loop.  So you just say:



   For Each qdf In db.QueryDefs

      If Left$(qdf.Name,4) = "qDel" Then

         qdf.Execute

      End If

   Next qdf



Cheers,



-Roy



   -----Original Message-----

From: Eddie Schott [mailto:eddie@p...]

Sent: Tuesday, May 08, 2001 2:37 PM

To: Access

Subject: [access] Using containers to run certain queries





Thanks to all who answered my delete all records question. I feel a bit

foolish for not thinking of the umm....er.....DELETE!!!!! query.



But now, I think I have a more advanced

question...



I have used the following code

(attached to the click event of a

command button) for running

all queries in an Access 97 database.



Private Sub cmdRunQueries_Click()

On Error GoTo Err_cmdRunQueries_Click



    Dim db As Database

    Dim qdf As QueryDef

    Set db = CurrentDb()

    db.QueryDefs.Refresh





    DoCmd.Hourglass True

    For Each qdf In db.QueryDefs

        qdf.Execute

    Next qdf

    DoCmd.Hourglass False



Exit_cmdRunQueries_Click:

    Exit Sub



Err_cmdRunQueries_Click:

    MsgBox Err.Description

    Resume Exit_cmdRunQueries_Click



End Sub



Now I would like to modify the code to run only queries that begin with

"qdel". I'm having a hard time figuring out what the syntax for exposing the

query name so that I can insert my IF THEN statement.



Can anyone help or give direction to the answers?



--

Eddie Schott

Progressive Action Network














Message #3 by Brian Skelton <brian_skelton@o...> on Tue, 8 May 2001 22:44:20 GMT
Eddie



Many objects have a Name property which holds, well, the name 

of the object. So the code you need is:



        If Left$(qdf.Name, 4) = "qdel" Then

            qdf.Execute

        End If



-BDS



----------------------------------------------------



I have used the following code

(attached to the click event of a

command button) for running

all queries in an Access 97 database.



Private Sub cmdRunQueries_Click()

On Error GoTo Err_cmdRunQueries_Click



    Dim db As Database

    Dim qdf As QueryDef

    Set db = CurrentDb()

    db.QueryDefs.Refresh





    DoCmd.Hourglass True

    For Each qdf In db.QueryDefs

        qdf.Execute

    Next qdf

    DoCmd.Hourglass False



Exit_cmdRunQueries_Click:

    Exit Sub



Err_cmdRunQueries_Click:

    MsgBox Err.Description

    Resume Exit_cmdRunQueries_Click



End Sub



Now I would like to modify the code to run only queries that 

begin with

"qdel". I'm having a hard time figuring out what the syntax 

for exposing the

query name so that I can insert my IF THEN statement.



Can anyone help or give direction to the answers?

Message #4 by "Eddie Schott" <eddie@p...> on Tue, 8 May 2001 16:21:23 -0700
Please disregard. I found the information in Help. It's amazing what you

find when you ask the question correctly.



Sorry for wasting anybody's time.







-----Original Message-----

From: Eddie Schott [mailto:eddie@p...]

Sent: Tuesday, May 08, 2001 2:37 PM

To: Access

Subject: Using containers to run certain queries





Thanks to all who answered my delete all records question. I feel a bit

foolish for not thinking of the umm....er.....DELETE!!!!! query.



But now, I think I have a more advanced

question...



I have used the following code

(attached to the click event of a

command button) for running

all queries in an Access 97 database.



Private Sub cmdRunQueries_Click()

On Error GoTo Err_cmdRunQueries_Click



    Dim db As Database

    Dim qdf As QueryDef

    Set db = CurrentDb()

    db.QueryDefs.Refresh





    DoCmd.Hourglass True

    For Each qdf In db.QueryDefs

        qdf.Execute

    Next qdf

    DoCmd.Hourglass False



Exit_cmdRunQueries_Click:

    Exit Sub



Err_cmdRunQueries_Click:

    MsgBox Err.Description

    Resume Exit_cmdRunQueries_Click



End Sub



Now I would like to modify the code to run only queries that begin with

"qdel". I'm having a hard time figuring out what the syntax for exposing the

query name so that I can insert my IF THEN statement.



Can anyone help or give direction to the answers?



--

Eddie Schott

Progressive Action Network









Message #5 by "Levine, Lloyd" <LEVINLL@m...> on Wed, 9 May 2001 08:43:01 -0400
Shouldn't you be able to get the query name by using the name property (ie.

qdf.name). You can then use the left() function to get the first four

characters of it's name.



-----Original Message-----

From: Eddie Schott [mailto:eddie@p...]

Sent: Tuesday, May 08, 2001 5:37 PM

To: Access

Subject: [access] Using containers to run certain queries





Thanks to all who answered my delete all records question. I feel a bit

foolish for not thinking of the umm....er.....DELETE!!!!! query.



But now, I think I have a more advanced

question...



I have used the following code

(attached to the click event of a

command button) for running

all queries in an Access 97 database.



Private Sub cmdRunQueries_Click()

On Error GoTo Err_cmdRunQueries_Click



    Dim db As Database

    Dim qdf As QueryDef

    Set db = CurrentDb()

    db.QueryDefs.Refresh





    DoCmd.Hourglass True

    For Each qdf In db.QueryDefs

        qdf.Execute

    Next qdf

    DoCmd.Hourglass False



Exit_cmdRunQueries_Click:

    Exit Sub



Err_cmdRunQueries_Click:

    MsgBox Err.Description

    Resume Exit_cmdRunQueries_Click



End Sub



Now I would like to modify the code to run only queries that begin with

"qdel". I'm having a hard time figuring out what the syntax for exposing the

query name so that I can insert my IF THEN statement.



Can anyone help or give direction to the answers?



--

Eddie Schott

Progressive Action Network

Message #6 by "Beverly Usher" <bUsher@h...> on Wed, 09 May 2001 16:12:32 +0100
I would like to use all of this (using a container to run queries) to

run a series of large delete and append queries on rather large files

(100,000-200,000 records) and run it overnight, but I would need to

capture any messages and warnings. I have dug around the help system but

can only find a reference to capturing messages on pass-through queries.

Is there any way to get the messages on append queries, and if so, can

you guide me to a good resource on it.



Thanks for any help,



Beverly



Message #7 by "Pardee, Roy E" <roy.e.pardee@l...> on Wed, 09 May 2001 14:34:31 -0700
This sounds like a daunting task to me--I'm not sure it's possible to

programmatically capture those warning messages.  The only strategy that

comes to mind is running your queries & then programmatically checking for

records that aren't where they should be (with 'find unmatched' type

queries).  Even then it may be tough to figure out exactly why a given

record didn't make it--was it a field-level validation problem, or a

table-level one, or a referential integrity violation, or some combination

of these, etc.



But maybe somebody else knows how to grab that warning message...



Cheers,



-Roy



-----Original Message-----

From: Beverly Usher [mailto:bUsher@h...]

Sent: Wednesday, May 09, 2001 8:13 AM

To: Access

Subject: [access] Re: Using containers to run certain queries





I would like to use all of this (using a container to run queries) to

run a series of large delete and append queries on rather large files

(100,000-200,000 records) and run it overnight, but I would need to

capture any messages and warnings. I have dug around the help system but

can only find a reference to capturing messages on pass-through queries.

Is there any way to get the messages on append queries, and if so, can

you guide me to a good resource on it.



Thanks for any help,



Beverly


  Return to Index