INSERT a record in tables

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
 
M

[MVP] S.Clark

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
 
S

shapper

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
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top