Re: Import Automation and...
From: John Nurick (j.mapSoN.nurick_at_dial.pipex.com)
Date: 02/04/05
- Next message: John Nurick: "Re: field name bug in import wizard"
- Previous message: withjam99: "Re: Exporting"
- In reply to: Chris via AccessMonster.com: "Re: Import Automation and..."
- Messages sorted by: [ date ] [ thread ]
Date: Fri, 04 Feb 2005 20:56:39 +0000
In that case I'd do it slightly differently inside that inner loop:
1) If there's no existing table, construct and execute a create-table
query (this is different from a make-table query, it creates an empty
table and lets you specify the primary key and stuff, which a make-table
query doesn't).
To find out whether the table already exists, you can use the function
at http://www.mvps.org/access/tables/tbl0001.htm.
The query will look something like this. Look in Access Help for
"Microsoft Jet SQL Reference", and in that for "Data Definition
Language".
CREATE TABLE TableName (
F1 CHAR (8),
F2 CHAR (255) CONSTRAINT PrKey PRIMARY KEY,
F3 CHAR (255),
F4 LONG
);
2) Now, wherever you started, there's a table to append to - so you
construct and execute an append query instead of a make-table query. It
will look something like this (both this and the CREATE TABLE sample
above assume that the second field is the one you want to be the primary
key:
INSERT INTO TableName
SELECT * FROM [textfile specification]
WHERE F2 NOT IN (SELECT F2 FROM TableName);
On Thu, 03 Feb 2005 19:46:06 GMT, "Chris via AccessMonster.com"
<forum@AccessMonster.com> wrote:
>Thank You so much for your help, I can't express this enough. This works
>just like I had wanted it too.
>
>I was just wondering...
>
>You left a hole in the code where you said
> '*** You may want to include code here to handle the
> 'situation where there is already a table of this
> 'name
>
>I would actually like to have it append to an existing table if the name
>already exists the only constraint is that a primary key is defined on the
>first table as I can't have duplicate email addresses. (We don't want to
>send the same promo twice to one person).
>
>I have found away to assign primary keys but I have not been able to fit it
>in the code for it to work.
-- John Nurick [Microsoft Access MVP] Please respond in the newgroup and not by email.
- Next message: John Nurick: "Re: field name bug in import wizard"
- Previous message: withjam99: "Re: Exporting"
- In reply to: Chris via AccessMonster.com: "Re: Import Automation and..."
- Messages sorted by: [ date ] [ thread ]
Relevant Pages
|