Importing Data in with DoCmd.TransferText In Related Tables

  • Thread starter Thread starter Chris
  • Start date Start date
C

Chris

Hi, I have the following problem with a one to many relation.
_________________________________________________
Parent Table:
Field_P1 , Field_P2
_________________________________________________
Child Table:
Field_C1, Field_C2, Field_C3, Field_C4, Field_C5
_________________________________________________
The above tables are related with a one-to-many ralation on fields
Field_P1<--->Feild_C1

I want to mass-import data into the child table from a delimited text
containing columns for fields:
Field_C2, Field_C3, Field_C4, Field_C5

The data will be imported for each record in the parent table.
I've tried to use the TransferText method of DoCmd but I'am
getting an error message about possible violation of referential integrity

(If I add another one column in the text file for the Field_C1 then it
seems to work fine but this is not the case because I dont want the
user to add the value. I think that the cascade-update rule would
do the job for me, but .......)

TIA, Chris
 
Hi,


The one side is probably the Parent table, the many side, the Child
table.

You want to append C2, C3, C4 and C5, without C1, in the Child table.
The only possible way to do it is by specifying a NULL under C1, for the new
records... if the table design allows NULL under C1.


You will then be obliged, probably, to change those NULL with the proper
value, a value under P1 of the parent table.

The "cascade" update cannot do some job for you, since the record, in
Parent, matching the record, in Child, is not determined as long as C1, in
the child, is not given.


There is no position, in itself, in a table. You cannot say: "match the
first record in Parent with the first record in Child", as long as Parent
and Child are only table. (For two recordsets, that would be different,
since there is definitively a position, in a recordset, such as MoveFirst to
reach the first record, and MoveNext to move to the next record... but NOT
in tables!)



Hoping it may help,
Vanderghast, Access MVP
 
Back
Top