Writes invalid record

G

Guest

I have a primary form and a sub-form all on a tab control form, that update
database a from primary form and database/table b from subform. They are
inter connected via Parent / Child links on primary keyed fields.

Problem exists if you write primary record a, tab to subform, write 1 or
many records from subform, as you tab back to primary panel, it wants to
write invalid record to table b. This write is because sequence number (not
autonum field is updated) and dirties the subform. The record itself has a
required field that if null, will not let the write occur, but, I want to get
rid of this error, and allow the user to tab to new panel without the error.
What do I have to check for: ON RETURN (close) works ok, I've check ON
UNLOAD, ON DEACTIVATE, ON LOST FOCUS, what switch gets set when you tab from
a subform back to a primary form?

Thanks in adavance
 
A

Allen Browne

Hi Robert

It sounds like you are assigning the new key value as soon as the subform
moves to a new record. A simple solution might be to delay the assignment
until the BeforeUpdate event of the *form*.

That's the last possible moment before the write takes place, so it will not
only solve the problem of assigning the value too early, but it will also
reduce the chance that 2 users are both given the same value when they try
to enter new records.

If you do want the value before then, use the BeforeInsert event of the
form. That occurs only when the user begins entering something, and so is
the earliest event that will prevent the problem.

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

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

message
news:[email protected]...
 

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