PC Review


Reply
Thread Tools Rate Thread

Create Conditional Make-Table Query

 
 
=?Utf-8?B?Sm9zZSBSdWJlbiBHb256YWxlei1CYWlyZA==?=
Guest
Posts: n/a
 
      23rd May 2007
I want to create a make table query that will only create a new table if the
results from its related select query returns any records.

For instance, i am running a select query that will compare two tables to
check to see if any records have changed. that query may of may not generate
records. if is DOES generate records, then when I run the related make-table
query, i want the query to make the select query table based on the condition
that the select query generated results.

if anyone has any suggestions i would greatly appreciate hearing them. thank
you, ruben.
 
Reply With Quote
 
 
 
 
John W. Vinson
Guest
Posts: n/a
 
      23rd May 2007
On Wed, 23 May 2007 13:03:01 -0700, Jose Ruben Gonzalez-Baird
<(E-Mail Removed)> wrote:

>I want to create a make table query that will only create a new table if the
>results from its related select query returns any records.
>
>For instance, i am running a select query that will compare two tables to
>check to see if any records have changed. that query may of may not generate
>records. if is DOES generate records, then when I run the related make-table
>query, i want the query to make the select query table based on the condition
>that the select query generated results.
>
>if anyone has any suggestions i would greatly appreciate hearing them. thank
>you, ruben.


MakeTable queries are, in my experience, very rarely needed. You're using the
term a "select query table" - do you mean a Select Query? or do you mean to
actually create a new, redundant, permanently stored table in your database?

It *sounds* like - and I may be mistaken here! - that you would be able to use
just a Select query bound to a Form. The user would click some button to open
the Form. In the Form's Load event you could check to see if the form's
recordsource contains any records; if not you could use Msgbox to issue a
message and quit, or if so, just proceed to display the form.

John W. Vinson [MVP]
 
Reply With Quote
 
dbahooker@hotmail.com
Guest
Posts: n/a
 
      23rd May 2007
this is easy in Access Data Projects

Create Procedure myConditionalMakeTable
AS
IF EXISTS (Select Records From vMyView)
BEGIN

Select *
Into tblMyView
>From vMyView


END



On May 23, 1:03 pm, Jose Ruben Gonzalez-Baird
<JoseRubenGonzalezBa...@discussions.microsoft.com> wrote:
> I want to create a make table query that will only create a new table if the
> results from its related select query returns any records.
>
> For instance, i am running a select query that will compare two tables to
> check to see if any records have changed. that query may of may not generate
> records. if is DOES generate records, then when I run the related make-table
> query, i want the query to make the select query table based on the condition
> that the select query generated results.
>
> if anyone has any suggestions i would greatly appreciate hearing them. thank
> you, ruben.



 
Reply With Quote
 
=?Utf-8?B?Sm9zZSBSdWJlbiBHb256YWxlei1CYWlyZA==?=
Guest
Posts: n/a
 
      23rd May 2007
John,

Thanks for your reply. What i'm actually doing is running queries in an
existing database. i want to "package" results from those Select queries into
a database that is "shipped" off for our reporting purposes.

So I'm running the Select queries in my existing database and then I want to
run the Make Table queries (and have the table(s) written to the the
reporting DB) IFF the Select queries return results. So the make table
queries will be almost exactly like the Select queries but will first check
to see if there are any results in the Select queries before writing to the
reporting DB (ideally).

I don't actually need the tables to be made in my existing DB, but I'd
rather have the make table query run if there were results in the Select
query. This way I don't have to individually export each query--it will be
written automatically to the reporting DB. Thanks, Ruben.

"John W. Vinson" wrote:

> On Wed, 23 May 2007 13:03:01 -0700, Jose Ruben Gonzalez-Baird
> <(E-Mail Removed)> wrote:
>
> >I want to create a make table query that will only create a new table if the
> >results from its related select query returns any records.
> >
> >For instance, i am running a select query that will compare two tables to
> >check to see if any records have changed. that query may of may not generate
> >records. if is DOES generate records, then when I run the related make-table
> >query, i want the query to make the select query table based on the condition
> >that the select query generated results.
> >
> >if anyone has any suggestions i would greatly appreciate hearing them. thank
> >you, ruben.

>
> MakeTable queries are, in my experience, very rarely needed. You're using the
> term a "select query table" - do you mean a Select Query? or do you mean to
> actually create a new, redundant, permanently stored table in your database?
>
> It *sounds* like - and I may be mistaken here! - that you would be able to use
> just a Select query bound to a Form. The user would click some button to open
> the Form. In the Form's Load event you could check to see if the form's
> recordsource contains any records; if not you could use Msgbox to issue a
> message and quit, or if so, just proceed to display the form.
>
> John W. Vinson [MVP]
>

 
Reply With Quote
 
John W. Vinson
Guest
Posts: n/a
 
      24th May 2007
On Wed, 23 May 2007 14:51:02 -0700, Jose Ruben Gonzalez-Baird
<(E-Mail Removed)> wrote:

>So I'm running the Select queries in my existing database and then I want to
>run the Make Table queries (and have the table(s) written to the the
>reporting DB) IFF the Select queries return results. So the make table
>queries will be almost exactly like the Select queries but will first check
>to see if there are any results in the Select queries before writing to the
>reporting DB (ideally).
>
>I don't actually need the tables to be made in my existing DB, but I'd
>rather have the make table query run if there were results in the Select
>query. This way I don't have to individually export each query--it will be
>written automatically to the reporting DB. Thanks, Ruben.


In that case, I'd suggest creating a "shipping" template database with all the
needed tables, empty. Link to this database from your production database, and
use Append queries to populate the empty tables.

This will avoid a lot of the annoyances (255 byte size for all Text fields,
missing or incorrect indexes, etc.) of make-table queries.

John W. Vinson [MVP]
 
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
Conditional Make Table Query KHogwood-Thompson Microsoft Access 5 29th Jan 2009 06:08 PM
How to Make Table query create a Yes/No field Phil Smith Microsoft Access Queries 2 22nd Feb 2008 01:34 AM
To have month and year as part of the table name in CREATE TABLE or MAKE TABLE Query ichew@scs.com.sg Microsoft Access Getting Started 1 18th Apr 2006 06:38 AM
Create Table Primary Key after Make Table Query And Update Table =?Utf-8?B?Uk5VU1pAT0tEUFM=?= Microsoft Access Queries 1 3rd May 2005 08:07 PM
How to create checkbox in make table query =?Utf-8?B?c2hhcnBlcg==?= Microsoft Access Queries 1 25th Jan 2005 08:09 PM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 06:38 AM.