PC Review


Reply
Thread Tools Rate Thread

Cancelling the addition of a new record

 
 
Pete
Guest
Posts: n/a
 
      18th Feb 2006
I currently have a form that has two subforms. One subform contains a
list of individuals and the other subform contains detailed information
associated with the individual.

Here is my problem. I the detail window, I have a command to add a new
record. If the user completes the record and clicks a save command,
the records is properly added. However, if the user adds a record
(docmd.gotorecord), begins to enter some data and then selects another
individual in the invidivual subform. The new records is added.

I need to stop (Cancel) this add when the subform switch occurs. I
have entered "LostFocus and DeActivate" events in the detail subform.
However, neither event is activated when the individual subform is
selected.

Any Ideas.

Thanks

 
Reply With Quote
 
 
 
 
Wayne Morgan
Guest
Posts: n/a
 
      18th Feb 2006
In the subform's BeforeUpdate procedure, use a message box to ask the user
if they want to save the changes. If they respond no, then Cancel the update
and Undo the form to get rid of the changes. To prevent the same prompt when
the Save button is clicked, you could have the Save button set the value of
a form level variable and check for this value in the form's BeforeUpdate
event. Skip the prompt if the value has been set, but remember to clear the
value to reset it for the next record.

--
Wayne Morgan
MS Access MVP


"Pete" <(E-Mail Removed)> wrote in message
news:(E-Mail Removed)...
>I currently have a form that has two subforms. One subform contains a
> list of individuals and the other subform contains detailed information
> associated with the individual.
>
> Here is my problem. I the detail window, I have a command to add a new
> record. If the user completes the record and clicks a save command,
> the records is properly added. However, if the user adds a record
> (docmd.gotorecord), begins to enter some data and then selects another
> individual in the invidivual subform. The new records is added.
>
> I need to stop (Cancel) this add when the subform switch occurs. I
> have entered "LostFocus and DeActivate" events in the detail subform.
> However, neither event is activated when the individual subform is
> selected.
>
> Any Ideas.
>
> Thanks
>



 
Reply With Quote
 
Pete
Guest
Posts: n/a
 
      18th Feb 2006
Wayne,
Thanks for the respose. It really helps to talk about a problem. The
problem turned out to be some corruption in the Detail form. Many of
the afterupdate events on the controls were not properly register in
the form. In these evetns a form variable was being set to trigger the
action in the BeforeUpdate. Since the events were never getting
triggered, the beforeupdate ignored the form wide variable.

Once I corrected the event links, everything worked correctly.

 
Reply With Quote
 
Pete
Guest
Posts: n/a
 
      18th Feb 2006
Wayne,
Thanks for the respose. It really helps to talk about a problem. The
problem turned out to be some corruption in the Detail form. Many of
the afterupdate events on the controls were not properly register in
the form. In these evetns a form variable was being set to trigger the
action in the BeforeUpdate. Since the events were never getting
triggered, the beforeupdate ignored the form wide variable.

Once I corrected the event links, everything worked correctly.

 
Reply With Quote
 
 
 
Reply

Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
problem cancelling a new record addition Paul Microsoft Access Forms 3 8th Aug 2009 05:11 AM
problem cancelling a new record addition Paul Microsoft Access Form Coding 3 8th Aug 2009 05:11 AM
Cancelling addition of new row scott Microsoft ADO .NET 1 29th Jun 2007 02:09 AM
Cancelling record John Microsoft Access Forms 1 26th Nov 2006 05:16 PM
Cancelling a new record addition =?Utf-8?B?bWFya3N0YWhs?= Microsoft Access Form Coding 2 10th Feb 2006 03:45 PM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 12:48 AM.