PC Review


Reply
Thread Tools Rate Thread

Append and Loop Code

 
 
JJ
Guest
Posts: n/a
 
      22nd Mar 2010
I am trying to create a code that will go through a table of criteria. It
will run a query for a row, append that query to an output table, and then
move down a row and do the same thing over until there are no rows left.

Example of Criteria_Table:

Fields are - AutoID: Name : Level : Location

456 : Joe : Level 1 : East
524 : Sam : Level 3 : West
789 : Bob : Level 10 : North


Example of Criteria_Qry (Criteria_Table linked Position_Table)

Fields are - Name : Level : Location : Position_Num


Example of Ouput_Table

Fields are - Name : Level : Location : Position_Num

Joe : Level 1 : East : 2
Sam : Level 3 : West : 6
Bob : Level 10 : North : 9

Any suggestions would be appreciated. Thanks!

 
Reply With Quote
 
 
 
 
Jeff Boyce
Guest
Posts: n/a
 
      22nd Mar 2010
Not clear what you intend by your expression "append that query to an output
table". Can I assume that you don't wish to have the query itself (i.e.,
the SQL statement), but the results of the query?

So, is this a little like asking Access to "find all the red ones" (and save
them in a new bucket), then "find all the green ones" (and save them in the
same bucket), then "find all ...?

If so, why are you saving them into an output table. Are you intending to
then use the found records in some kind of report? If so, don't limit
yourself! Use a query that pulls together all those separate query results
(this is called a UNION query), and use THAT as your source for your report.

.... or maybe I'm reading too much into what you described!

Good luck!

Regards

Jeff Boyce
Microsoft Access MVP

--
Disclaimer: This author may have received products and services mentioned
in this post. Mention and/or description of a product or service herein
does not constitute endorsement thereof.

Any code or pseudocode included in this post is offered "as is", with no
guarantee as to suitability.

You can thank the FTC of the USA for making this disclaimer
possible/necessary.

"JJ" <(E-Mail Removed)> wrote in message
news:61582C6E-2914-42B6-9FAF-(E-Mail Removed)...
>I am trying to create a code that will go through a table of criteria. It
> will run a query for a row, append that query to an output table, and then
> move down a row and do the same thing over until there are no rows left.
>
> Example of Criteria_Table:
>
> Fields are - AutoID: Name : Level : Location
>
> 456 : Joe : Level 1 : East
> 524 : Sam : Level 3 : West
> 789 : Bob : Level 10 : North
>
>
> Example of Criteria_Qry (Criteria_Table linked Position_Table)
>
> Fields are - Name : Level : Location : Position_Num
>
>
> Example of Ouput_Table
>
> Fields are - Name : Level : Location : Position_Num
>
> Joe : Level 1 : East : 2
> Sam : Level 3 : West : 6
> Bob : Level 10 : North : 9
>
> Any suggestions would be appreciated. Thanks!
>



 
Reply With Quote
 
JJ
Guest
Posts: n/a
 
      22nd Mar 2010
Yes Jeff,

Good call. I would like to use a Union Query if possible. The end results
will be used for a report. Basically the criteria table will have a different
set of criteria on each row of the table. I need to keep quering the main
table with each row of the criteria table until all the rows are accounted
for.

"Jeff Boyce" wrote:

> Not clear what you intend by your expression "append that query to an output
> table". Can I assume that you don't wish to have the query itself (i.e.,
> the SQL statement), but the results of the query?
>
> So, is this a little like asking Access to "find all the red ones" (and save
> them in a new bucket), then "find all the green ones" (and save them in the
> same bucket), then "find all ...?
>
> If so, why are you saving them into an output table. Are you intending to
> then use the found records in some kind of report? If so, don't limit
> yourself! Use a query that pulls together all those separate query results
> (this is called a UNION query), and use THAT as your source for your report.
>
> .... or maybe I'm reading too much into what you described!
>
> Good luck!
>
> Regards
>
> Jeff Boyce
> Microsoft Access MVP
>
> --
> Disclaimer: This author may have received products and services mentioned
> in this post. Mention and/or description of a product or service herein
> does not constitute endorsement thereof.
>
> Any code or pseudocode included in this post is offered "as is", with no
> guarantee as to suitability.
>
> You can thank the FTC of the USA for making this disclaimer
> possible/necessary.
>
> "JJ" <(E-Mail Removed)> wrote in message
> news:61582C6E-2914-42B6-9FAF-(E-Mail Removed)...
> >I am trying to create a code that will go through a table of criteria. It
> > will run a query for a row, append that query to an output table, and then
> > move down a row and do the same thing over until there are no rows left.
> >
> > Example of Criteria_Table:
> >
> > Fields are - AutoID: Name : Level : Location
> >
> > 456 : Joe : Level 1 : East
> > 524 : Sam : Level 3 : West
> > 789 : Bob : Level 10 : North
> >
> >
> > Example of Criteria_Qry (Criteria_Table linked Position_Table)
> >
> > Fields are - Name : Level : Location : Position_Num
> >
> >
> > Example of Ouput_Table
> >
> > Fields are - Name : Level : Location : Position_Num
> >
> > Joe : Level 1 : East : 2
> > Sam : Level 3 : West : 6
> > Bob : Level 10 : North : 9
> >
> > Any suggestions would be appreciated. Thanks!
> >

>
>
> .
>

 
Reply With Quote
 
Jeff Boyce
Guest
Posts: n/a
 
      22nd Mar 2010
OK, I can see that if you'll be working through a table of various selection
criteria, it might be tough to preserve the results of each row's selected
records without having someplace to stuff them!

A couple ideas come to mind -- first, yours. A temporary table to collect
all those before using the data in that table for your report. A possible
alternative might be to create an Array and write the found data elements
into the array, then use the array as your recordset for the report. A temp
table would be much easier if you haven't worked in the code that much.

Good luck!

Regards

Jeff Boyce
Microsoft Access MVP

--
Disclaimer: This author may have received products and services mentioned
in this post. Mention and/or description of a product or service herein
does not constitute endorsement thereof.

Any code or pseudocode included in this post is offered "as is", with no
guarantee as to suitability.

You can thank the FTC of the USA for making this disclaimer
possible/necessary.

"JJ" <(E-Mail Removed)> wrote in message
news:F73F782B-99F4-416D-9994-(E-Mail Removed)...
> Yes Jeff,
>
> Good call. I would like to use a Union Query if possible. The end results
> will be used for a report. Basically the criteria table will have a
> different
> set of criteria on each row of the table. I need to keep quering the main
> table with each row of the criteria table until all the rows are accounted
> for.
>
> "Jeff Boyce" wrote:
>
>> Not clear what you intend by your expression "append that query to an
>> output
>> table". Can I assume that you don't wish to have the query itself (i.e.,
>> the SQL statement), but the results of the query?
>>
>> So, is this a little like asking Access to "find all the red ones" (and
>> save
>> them in a new bucket), then "find all the green ones" (and save them in
>> the
>> same bucket), then "find all ...?
>>
>> If so, why are you saving them into an output table. Are you intending
>> to
>> then use the found records in some kind of report? If so, don't limit
>> yourself! Use a query that pulls together all those separate query
>> results
>> (this is called a UNION query), and use THAT as your source for your
>> report.
>>
>> .... or maybe I'm reading too much into what you described!
>>
>> Good luck!
>>
>> Regards
>>
>> Jeff Boyce
>> Microsoft Access MVP
>>
>> --
>> Disclaimer: This author may have received products and services mentioned
>> in this post. Mention and/or description of a product or service herein
>> does not constitute endorsement thereof.
>>
>> Any code or pseudocode included in this post is offered "as is", with no
>> guarantee as to suitability.
>>
>> You can thank the FTC of the USA for making this disclaimer
>> possible/necessary.
>>
>> "JJ" <(E-Mail Removed)> wrote in message
>> news:61582C6E-2914-42B6-9FAF-(E-Mail Removed)...
>> >I am trying to create a code that will go through a table of criteria.
>> >It
>> > will run a query for a row, append that query to an output table, and
>> > then
>> > move down a row and do the same thing over until there are no rows
>> > left.
>> >
>> > Example of Criteria_Table:
>> >
>> > Fields are - AutoID: Name : Level : Location
>> >
>> > 456 : Joe : Level 1 : East
>> > 524 : Sam : Level 3 : West
>> > 789 : Bob : Level 10 : North
>> >
>> >
>> > Example of Criteria_Qry (Criteria_Table linked Position_Table)
>> >
>> > Fields are - Name : Level : Location : Position_Num
>> >
>> >
>> > Example of Ouput_Table
>> >
>> > Fields are - Name : Level : Location : Position_Num
>> >
>> > Joe : Level 1 : East : 2
>> > Sam : Level 3 : West : 6
>> > Bob : Level 10 : North : 9
>> >
>> > Any suggestions would be appreciated. Thanks!
>> >

>>
>>
>> .
>>



 
Reply With Quote
 
 
 
Reply

Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Re: VBA code to loop append query fails John Spencer Microsoft Access VBA Modules 1 16th Mar 2009 09:18 PM
Loop using append query Martin Microsoft Access VBA Modules 3 1st Oct 2008 06:04 PM
Loop and append to different worksheets Dow Microsoft Excel Programming 5 18th Mar 2008 04:43 PM
Code to Loop a Paste Append x times =?Utf-8?B?U2FuZHk=?= Microsoft Access VBA Modules 16 29th Feb 2008 07:12 AM
Append Table with Loop =?Utf-8?B?RG9yY2k=?= Microsoft Access VBA Modules 13 11th Mar 2005 05:09 PM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 12:51 PM.