P
Phil Reynolds
I have two tables: table A (parent) and table B (child) which have a
one-to-many relationship. Fields A.1 and B.1 are both the primary key fields
of tables A and B, and each is an autonumber field. Field B.2 is the foreign
key field which links to field A.1.
I have a query with SQL as follows:
SELECT B.*, A.1, A.2
FROM B INNER JOIN A ON B.2 = A.1
ORDER BY B.1
When I open the query and go to the new record, I enter in B.2 the value for
A.1 for one of the existing A records. The new record is added in the B
table. No problem.
However, when I base a form on the above SQL and then try to add a record, I
am unable to do so.
In the form's BeforeInsert event, I have the following code:
Me!2 = lngVariableContainingA1value
(the field is not really called 2; I just use that to show that it's the
"B.2" field noted above).
When I type a value in the form (corresponding to one of the B fields, such
as B.3 or whatever), the above BeforeInsert code executes, and I get the
error: "Field cannot be updated" (error 3164).
What am I doing wrong? Thanks!
one-to-many relationship. Fields A.1 and B.1 are both the primary key fields
of tables A and B, and each is an autonumber field. Field B.2 is the foreign
key field which links to field A.1.
I have a query with SQL as follows:
SELECT B.*, A.1, A.2
FROM B INNER JOIN A ON B.2 = A.1
ORDER BY B.1
When I open the query and go to the new record, I enter in B.2 the value for
A.1 for one of the existing A records. The new record is added in the B
table. No problem.
However, when I base a form on the above SQL and then try to add a record, I
am unable to do so.
In the form's BeforeInsert event, I have the following code:
Me!2 = lngVariableContainingA1value
(the field is not really called 2; I just use that to show that it's the
"B.2" field noted above).
When I type a value in the form (corresponding to one of the B fields, such
as B.3 or whatever), the above BeforeInsert code executes, and I get the
error: "Field cannot be updated" (error 3164).
What am I doing wrong? Thanks!