S
srob
I have a table "customer" which has a one-to-many relationship with
table "addresses". The primary key of "customer" is an autonumber
field. I have a form that displays the customers, and allows you to
add a new customer. Also on this form is a command button that uses
VBA code to add additional addresses for the current customer. My
problem is that when I create a new customer and immediately try to add
addresses, the VBA code fails. If I move back a record and then
forward a record on the form then the VBA code works for the newly
added customer.
I think I need to update the "customer" table on the form when I exit
the first field. How can I do this?
Interestingly, in my VBA code, the line
CustomerID = Forms![customer]!custormerID
returns the correct customer ID of the just added customer, however
when I try to update the address table with;
With rst_addressess
.AddNew ' Add new record.
!customerID = CustomerID ' Add data.
.Update
end with
I get an error when I try to execute the .Update statement.
table "addresses". The primary key of "customer" is an autonumber
field. I have a form that displays the customers, and allows you to
add a new customer. Also on this form is a command button that uses
VBA code to add additional addresses for the current customer. My
problem is that when I create a new customer and immediately try to add
addresses, the VBA code fails. If I move back a record and then
forward a record on the form then the VBA code works for the newly
added customer.
I think I need to update the "customer" table on the form when I exit
the first field. How can I do this?
Interestingly, in my VBA code, the line
CustomerID = Forms![customer]!custormerID
returns the correct customer ID of the just added customer, however
when I try to update the address table with;
With rst_addressess
.AddNew ' Add new record.
!customerID = CustomerID ' Add data.
.Update
end with
I get an error when I try to execute the .Update statement.