saving new record in subform

G

Guest

The main form is frmCustomers, with a subform subfrmContacts. The subform
has custom navigation buttons, cmdAddContact and cmdDeleteContact. On the
subform, AllowAdditions = false. When the user clicks cmdAddContact, I set
AllowAdditions = true. On the AfterInsert Event, I set the AllowAdditions
back to false.

If the user clicks cmdAddContact, then types in the info, then clicks
cmdAddContact again, it says, "can't go to the specified record." If I click
outside the subform, then back in the subform, I can add a record. I need a
better solution!

Thank you,
Steve
 
A

Allen Browne

Steve, you can use several kludges to ensure the main form has its
AllowEdits set to Yes (you can't operate the subform if it doesn't),
SetFocus to fudge the movement to main form and back and so on.

Or, you could simply leave the subform's AllowAdditions set to True and
avoid the whole problem. Instead cancel the subform's BeforeInsert event if
the user is not allowed to add the record.

This also solves the issue of the subform going completely blank when there
are no records to display (e.g. filtered) and no new record can be added.
 

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