PC Review


Reply
Thread Tools Rate Thread

Automate make table query

 
 
=?Utf-8?B?SmVmZg==?=
Guest
Posts: n/a
 
      7th Sep 2006

I have a large table with the columns=
State; PolicyNumber; Age; ClaimAmount

I want to create 50 tables and export these into excel.
I have a make table query that takes the large table and sums the claim
amount by age. So for Texas the table would look like

State; Age; SummedClaimAmount

I need to do this for each state and
I want to automate the process because typing in CT run query, then MA run
query, etc... gets very tedious.

Is it possible to create a macro to automate this.

I am thinking it would look like something like
Sub()
Dim StateName(50) as Array

StateName(1) = "CT", ...

For i = 1 to 50
run query on StateName(i)
Ouput table into excel with filename = StateName(i)&"StateTable.xls"
Next i
End Sub

Thanks for your help.


 
Reply With Quote
 
 
 
 
Douglas J. Steele
Guest
Posts: n/a
 
      7th Sep 2006
Why? As in why do you think you need to create 50 tables?

You can create a parameter query, pass it the state you want and export the
query.

You really should have a table that contains the information about the 50
states, rather than setting a 50 element array in your code.

--
Doug Steele, Microsoft Access MVP
http://I.Am/DougSteele
(no e-mails, please!)


"Jeff" <(E-Mail Removed)> wrote in message
news:5E02C7F5-EC4A-4D22-A428-(E-Mail Removed)...
>
> I have a large table with the columns=
> State; PolicyNumber; Age; ClaimAmount
>
> I want to create 50 tables and export these into excel.
> I have a make table query that takes the large table and sums the claim
> amount by age. So for Texas the table would look like
>
> State; Age; SummedClaimAmount
>
> I need to do this for each state and
> I want to automate the process because typing in CT run query, then MA run
> query, etc... gets very tedious.
>
> Is it possible to create a macro to automate this.
>
> I am thinking it would look like something like
> Sub()
> Dim StateName(50) as Array
>
> StateName(1) = "CT", ...
>
> For i = 1 to 50
> run query on StateName(i)
> Ouput table into excel with filename = StateName(i)&"StateTable.xls"
> Next i
> End Sub
>
> Thanks for your help.
>
>



 
Reply With Quote
 
=?Utf-8?B?S0FSTCBERVdFWQ==?=
Guest
Posts: n/a
 
      7th Sep 2006
Use one table instead of 50. The State field is enough identity and one
totals query would group on the State field.

"Jeff" wrote:

>
> I have a large table with the columns=
> State; PolicyNumber; Age; ClaimAmount
>
> I want to create 50 tables and export these into excel.
> I have a make table query that takes the large table and sums the claim
> amount by age. So for Texas the table would look like
>
> State; Age; SummedClaimAmount
>
> I need to do this for each state and
> I want to automate the process because typing in CT run query, then MA run
> query, etc... gets very tedious.
>
> Is it possible to create a macro to automate this.
>
> I am thinking it would look like something like
> Sub()
> Dim StateName(50) as Array
>
> StateName(1) = "CT", ...
>
> For i = 1 to 50
> run query on StateName(i)
> Ouput table into excel with filename = StateName(i)&"StateTable.xls"
> Next i
> End Sub
>
> Thanks for your help.
>
>

 
Reply With Quote
 
=?Utf-8?B?SmVmZg==?=
Guest
Posts: n/a
 
      7th Sep 2006
I have to create 50 tables, can you just answer the Question

Thanks


"KARL DEWEY" wrote:

> Use one table instead of 50. The State field is enough identity and one
> totals query would group on the State field.
>
> "Jeff" wrote:
>
> >
> > I have a large table with the columns=
> > State; PolicyNumber; Age; ClaimAmount
> >
> > I want to create 50 tables and export these into excel.
> > I have a make table query that takes the large table and sums the claim
> > amount by age. So for Texas the table would look like
> >
> > State; Age; SummedClaimAmount
> >
> > I need to do this for each state and
> > I want to automate the process because typing in CT run query, then MA run
> > query, etc... gets very tedious.
> >
> > Is it possible to create a macro to automate this.
> >
> > I am thinking it would look like something like
> > Sub()
> > Dim StateName(50) as Array
> >
> > StateName(1) = "CT", ...
> >
> > For i = 1 to 50
> > run query on StateName(i)
> > Ouput table into excel with filename = StateName(i)&"StateTable.xls"
> > Next i
> > End Sub
> >
> > Thanks for your help.
> >
> >

 
Reply With Quote
 
Smartin
Guest
Posts: n/a
 
      8th Sep 2006
Jeff wrote:
> I have a large table with the columns=
> State; PolicyNumber; Age; ClaimAmount
>
> I want to create 50 tables and export these into excel.
> I have a make table query that takes the large table and sums the claim
> amount by age. So for Texas the table would look like
>
> State; Age; SummedClaimAmount
>
> I need to do this for each state and
> I want to automate the process because typing in CT run query, then MA run
> query, etc... gets very tedious.
>
> Is it possible to create a macro to automate this.
>
> I am thinking it would look like something like
> Sub()
> Dim StateName(50) as Array
>
> StateName(1) = "CT", ...
>
> For i = 1 to 50
> run query on StateName(i)
> Ouput table into excel with filename = StateName(i)&"StateTable.xls"
> Next i
> End Sub
>
> Thanks for your help.
>
>


It would be simpler to have a table on hand with each of the states
rather than setting up an array in code, but either would work. This
stub might give you some ideas. This will be done in a standard module
using VBA:

Populate a recordset or array with the states
Walk through the recordset/array
Execute make table query using the current state
Export the new table to XLS worksheet
loop

--
Smartin
 
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
automate a make table query =?Utf-8?B?SmFuaXM=?= Microsoft Access Queries 5 20th Sep 2007 12:09 AM
Automate question answers in make-table query =?Utf-8?B?c3RpY2thbmRyb2Nr?= Microsoft Access Queries 1 24th Apr 2006 03:54 PM
automate make table query =?Utf-8?B?TWljaGVsbGUgSw==?= Microsoft Access Queries 3 1st Aug 2005 03:15 PM
Automate running several make table queries SimonJester@moose-mail.com Microsoft Access 3 10th Jan 2005 11:59 PM
Automate make table query Allison Microsoft Access Queries 3 23rd Apr 2004 06:52 PM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 12:59 AM.