Run SQL In Subform With Relationships Established

  • Thread starter Larry R Harrison Jr
  • Start date
L

Larry R Harrison Jr

I have an Access 97 database with 2 tables that have a one-many
relationship. I have a SQL statement in the "one" table which I want to
execute and insert 7 records into the "many" table, and I want them to be
linked to the "main" table.

Problem is, it won't let me run the SQL run as long as the one-many
relationship is established in the relationship window.

The SQL is:

Dim sSQL As String
For stDate = stBegDate To stEndDate
sSQL = "INSERT INTO tblScheduleActual_Test ( date1 ) SELECT #" & stDate & "#
AS Expr1;"
DoCmd.RunSQL sSQL
Next stDate

It loops through the dates of the week and inserts 7 records with successive
dates.

It works fine if I remove the relationship, but I figured the relationship
should be established in the relationship window.

Tips?

LRH
 
L

Larry R Harrison Jr

Allen Browne said:
Don't you need to insert two fields:
- a foreign key value, and
- the date?

--
Allen Browne - Microsoft MVP. Perth, Western Australia.

Reply to group, rather than allenbrowne at mvps dot org.
&
 
L

Larry R Harrison Jr

Allen Browne said:
Don't you need to insert two fields:
- a foreign key value, and
- the date?
Yeah you're right. I did that, problem fixed.

Geez, how simple was that? :)

LRH
 

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