Save record on subform? PLEASE help!

R

Rodi

I'm sorry; I just don't get it and I need assistence.

I have a form with a couple of subforms. The user is supposed to be able to
access the customer information on the main form, then click a command button
that brings up a subform. Once in the subform, the user is supposed to be
able to add equipment data that is attached to that customer. The equipment
may exist; it may not. If it does exist, all I want do to is to be able to
get the user to update the existing equipment record by way of attaching it
to the customer.

So, I have code that will allow the user to input the equipment ID, then
search the databse and populate the rest of the subform with the rest of the
equipment record. Next, I just want to be able to exit the subform without
the system thinking I'm trying to add a record that already exists!

For example, I attached a piece of equipment to a customer. I then tried to
go to the next record and, predictably, got a message stating "...the record
already existed, blah, blah, blah...". I tried just closing the subform and
received a similar message. I tried coding a docmd.GoToRecord and
DoCmd.RunCommand asRecordsGoToNew/GoToNext, all to no avail.

Am I missing a basic function of the database?
Right now, I'm feeling like the worst db person since the first abacus was
created. Any help is greatly appreciated.

Thanks.
 
A

Alex Dybenko

Hi,
you can use form's Error event to detect error number and then for duplicate
records error undo the entry
 
R

Rodi

I gave that a shot, but the error wasn't captured, which, on reflection,
seems to make sense as the error is soming right from the datasbe itself and
not VBA.

That still leaves me with the original quandry; trying to update the
database, which I can programmatically, then exit the subform, bypassing the
attempt by Access to add the record to the database. Am I out of luck? Is
this a basic functionality I around which I can't work?

Thanks again.
 
A

Alex Dybenko

Hi,
perhaps you used wrong event, or something else. please try again. i always
use error event to catch such kind of error and process then there. once you
enter records in a form - error "comes" from database to form.
 

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