INSERT a record in tables

  • Thread starter Thread starter shapper
  • Start date Start date
S

shapper

Hello,

I have two tables with the following fields:

1. Table "web_Content"

Fields: [ContentId] > Primary Key;
[ContentName];
[ContentPage].

2. Table "web_ContentLocalized"

Fields: [Content_LocalizedId] > Primary Key
[ContentId] > Joined to ContentId in table "web_Content"
[ContentCulture]
[ContentHtml]

I want to INSERT a new record in both databases.
What I mean is that a new record will add values to [ContentName];
[ContentPage]; [ContentCulture] and [ContentHtml].

[ContentId] and [Content_LocalizedId] are autonumbers.

[ContentId] in table "web_ContentLocalized" should be the same as in
[ContentId] of "web_Content" table.

Anyway, I tried but until now I was able to make this work.

This is what I have:

INSERT INTO web_Content ( ContentPage, ContentName )
SELECT web_Content.ContentPage, web_Content.ContentName
FROM web_Content INNER JOIN web_ContentLocalized ON
web_Content.ContentId = web_ContentLocalized.ContentId;

Thanks,
Miguel
 
I think the problem you're having is knowing the ContentID of the parent to
put into the child table. I skirt this by adding the record to the parent
with VBA and getting the new ID after issuing the AddNew method. Then the
new ID can be used to populate the child records.

--
Steve Clark, Access MVP
FMS, Inc
http://www.fmsinc.com/consulting
Professional Access Database Repair
*FREE* Access Tips: http://www.fmsinc.com/free/tips.html
 
Sorry,

I am lost now. I am not very good with Queries.
Could you, please, give me an example?

Thansks,
Miguel

[MVP] S.Clark said:
I think the problem you're having is knowing the ContentID of the parent to
put into the child table. I skirt this by adding the record to the parent
with VBA and getting the new ID after issuing the AddNew method. Then the
new ID can be used to populate the child records.

--
Steve Clark, Access MVP
FMS, Inc
http://www.fmsinc.com/consulting
Professional Access Database Repair
*FREE* Access Tips: http://www.fmsinc.com/free/tips.html

shapper said:
Hello,

I have two tables with the following fields:

1. Table "web_Content"

Fields: [ContentId] > Primary Key;
[ContentName];
[ContentPage].

2. Table "web_ContentLocalized"

Fields: [Content_LocalizedId] > Primary Key
[ContentId] > Joined to ContentId in table "web_Content"
[ContentCulture]
[ContentHtml]

I want to INSERT a new record in both databases.
What I mean is that a new record will add values to [ContentName];
[ContentPage]; [ContentCulture] and [ContentHtml].

[ContentId] and [Content_LocalizedId] are autonumbers.

[ContentId] in table "web_ContentLocalized" should be the same as in
[ContentId] of "web_Content" table.

Anyway, I tried but until now I was able to make this work.

This is what I have:

INSERT INTO web_Content ( ContentPage, ContentName )
SELECT web_Content.ContentPage, web_Content.ContentName
FROM web_Content INNER JOIN web_ContentLocalized ON
web_Content.ContentId = web_ContentLocalized.ContentId;

Thanks,
Miguel
 
Back
Top