Suspend an OnCurrent Event?

S

Sandra

I have a "People" form with a "Campaign" subform. The
OnCurrent Event of People sets AllowEdits,
AllowAdditions, AllowDeletions to False.

I have an EDIT button to edit the record that sets the
Allows to True. I have a NEW button that also sets the
Allows to True.

For existing records this works OK, but when entering
data in a new record if I move from the People form to
the Campaign form and back, the OnCurrent event must be
called because all the Allows are set back to False.
This means I cannot complete the entry in the People form
unless I hit the EDIT button to reset the Allows again.

Is there a way I can "suspend" or cancel the OnCurrent
event when I click the NEW button?

Thanks,
Sandra
 
A

Allen Browne

Access saves the main record before it allows the focus to move into the
subform. Once that main form record is saved, it is no longer at a new
record. That's the reason you have to allow edits if you want to change it
further.

It may be possible to work around the situation by creating a form-level
boolean variable (one declared at the top of the main form's module, with
the Option statements), and setting its values to track if this was a
recently created record, and set your AllowEdits accordingly. A better
solution might be to add a field to store the date and time the record was
created. Just set the field's Default Value property ot =Now(). You could
then conditioally toggle the form's AllowEdits property, depending on
whether the record was created in the last xx minutes.
 
R

Reggie

Sandra, You could place a checkbox on your form(visible = no) and when you
click the new button set it to true then on the oncurrent event use an if
statement to check the value of the control.
If Me.chkOne = True Then
exit sub
Else
..run this code
End If

One question though. If the user can edit the form just by clicking the
buttons, why not just open the form in the edit condition. Doesn't seem
like you're accomplishing much by this extra step. Just my thoughts!
 
G

Guest

"If the user can edit the form just by clicking the
buttons, why not just open the form in the edit
condition."

That was my first idea LOL! But...the same scenario
happens if you open in edit mode and click the "new"
symbol on the navigation bar. The minute you move from
form A to form B then back to form A it switches back to
non-edit mode (I presume being triggered by the same
OnCurrent event).

This db is for a charity that uses volunteers with
minimum db skills. We have had so many problems with mis-
edits and such, I am trying to work out a schema that
will provide the best possible protection for the
records. The "click this" philosophy at least requires
an intuitive action on the part of the user before the
record can be edited, rather than what usually happens
and they start typing in the fields before they hit the
FIND button LOL! If I can just work out this glitch with
new records we would be in pretty good shape...

Sandra
 

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