Transfer data between tables - problem with unique ID (1 Viewer)

Clueless Newbie

Immortal. So far.
Local time
Today, 10:11
Joined
Feb 6, 2004
Messages
48
Hi all!

I'm trying to transfer data between two tables. This is the corresponding query:

INSERT INTO tblData ( KundenNr, AngebotNr, LaufzeitSAP, SAPAuftragsWert )
SELECT tblExcelimport.Debitor, tblExcelimport.SaM, tblExcelimport.Laufzeit, tblExcelimport.Wert
FROM tblExcelimport
WHERE (((tblExcelimport.Laufzeit)=9999) AND ((tblExcelimport.Wert)=0));

The problem is that tblData contains an ID field whose value needs to be unique, but unfortunately it's not an auto-increment type. So far, tblData.ID is simply = 0 for every recordset I add through the above query - which of course is not acceptable. (tblExcelimport has no ID field so far, but of course I could add one and adjust my query accordingly.)

Is there any way to determine DMax("[ID]", "tblData"), let tblExcelimport.ID count up from there and then insert those recordsets into tblData, or something along that line?

Probably sounds daft to you experts, but I'm lost... :confused: Any ideas would be most appreciated. Thank you! :)

Ute
 

Tim K.

Registered User.
Local time
Today, 09:11
Joined
Aug 1, 2002
Messages
242
I think you have to add a Number field to the tblExcelimport. Then loop thru its records and assign the newly added field with the DMax("[ID]", "tblData").
Then you can append it to the tblData. How this sounds to you?

:)
 

Clueless Newbie

Immortal. So far.
Local time
Today, 10:11
Joined
Feb 6, 2004
Messages
48
In theory this works fine, thank you! :)

But I've just received a mail that this feature isn't wanted anymore... :rolleyes:
 

Ron_dK

Cool bop aficionado
Local time
Today, 10:11
Joined
Sep 5, 2002
Messages
2,141
Ute,

I had a similar thing in my Dbase and resolved it thru importing data in a table ( Tb Import). This table contains a load date. By means of a macro imported data is transfered to my working table e.g. TbWorking. Only data which has changed is transfered to TbWorking. At the same time , when importing data in the TbImport , all previous data is cleared, and the Import-ID starts with
the last number.
Hope this makes sense.

Cheers, Ron
 

Users who are viewing this thread

Top Bottom