A Microsoft Office (Excel, Word) forum. OfficeFrustration

If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

Go Back   Home » OfficeFrustration forum » Microsoft Access » Using Forms
Site Map Home Register Authors List Search Today's Posts Mark Forums Read  

BeforeUpdate doesn't always fire



 
 
Thread Tools Display Modes
  #11  
Old February 10th, 2010, 07:19 AM posted to microsoft.public.access.forms
.Len B
external usenet poster
 
Posts: 81
Default BeforeUpdate doesn't always fire

I'm sorry Jeanette, you've lost me.
I have a main form, frmEnterNotes containing a subform control
called subfrmNote.

Inside the subfrmNote control is the subform called subfrmNoteNow.

subfrmNoteNow has the BeforeUpdate event where my posted validation
code lives. This code runs fine if I deliberately try to save the
detail record from within the subform using cmdSave. The record is
validated, saved and a new blank record is presented ready to enter
another note for this parent record.
It is only if I do not complete the subform normally that the problem
arises. Example, If I do anything outside the subform, the validation
code is somehow bypassed and the record is saved regardless of its
validity.

I think what you are saying is what I am doing. If not please say
what I should do. I only used the Exit event to provide somewhere
to put a DoEvents to set a breakpoint. That will go; no point to it.

--
Len
__________________________________________________ ____
remove nothing for valid email address.
"Jeanette Cunningham" wrote in message
...
| Ah Hah! Use the before update event on the form that you put inside the
| subform control.
| This explains the strange results you were getting.
| It's not the subform control where you validate data, it's the form
| (subform) inside the subform control.
| Sometimes both the subform and the subform control have the same name,
| sometimes they don't.
|
| By the way, it's best not to use exit events of controls to validate
data -
| causes problems and is best avoided.
|
|
| Jeanette Cunningham MS Access MVP -- Melbourne Victoria Australia



  #12  
Old February 10th, 2010, 10:44 AM posted to microsoft.public.access.forms
Jeanette Cunningham
external usenet poster
 
Posts: 2,190
Default BeforeUpdate doesn't always fire

I haven't come across this situation before.
If you set a break point on the subform's before update event in the code
window,
open the form in normal view,
do enough data entry to make the subform dirty and leave a required field
empty,
then click back on the main form,
does the code window open and allow you to step through the before update
event for the subform?


Jeanette Cunningham MS Access MVP -- Melbourne Victoria Australia


".Len B" wrote in message
...
I'm sorry Jeanette, you've lost me.
I have a main form, frmEnterNotes containing a subform control
called subfrmNote.

Inside the subfrmNote control is the subform called subfrmNoteNow.

subfrmNoteNow has the BeforeUpdate event where my posted validation
code lives. This code runs fine if I deliberately try to save the
detail record from within the subform using cmdSave. The record is
validated, saved and a new blank record is presented ready to enter
another note for this parent record.
It is only if I do not complete the subform normally that the problem
arises. Example, If I do anything outside the subform, the validation
code is somehow bypassed and the record is saved regardless of its
validity.

I think what you are saying is what I am doing. If not please say
what I should do. I only used the Exit event to provide somewhere
to put a DoEvents to set a breakpoint. That will go; no point to it.

--
Len
__________________________________________________ ____
remove nothing for valid email address.
"Jeanette Cunningham" wrote in message
...
| Ah Hah! Use the before update event on the form that you put inside the
| subform control.
| This explains the strange results you were getting.
| It's not the subform control where you validate data, it's the form
| (subform) inside the subform control.
| Sometimes both the subform and the subform control have the same name,
| sometimes they don't.
|
| By the way, it's best not to use exit events of controls to validate
data -
| causes problems and is best avoided.
|
|
| Jeanette Cunningham MS Access MVP -- Melbourne Victoria Australia





  #13  
Old February 10th, 2010, 10:46 AM posted to microsoft.public.access.forms
.Len B
external usenet poster
 
Posts: 81
Default BeforeUpdate doesn't always fire

I was surprised to see that the code was compiled after I had just
done a decompile. I wondered if it really did decompile.

--
Len
__________________________________________________ ____
remove nothing for valid email address.
"Jeanette Cunningham" wrote in message
...
| When Compile is greyed out, all the code is compiled.
| Once you start to edit some of the code, it will become uncompiled.
| We usually click Debug | Compile every time we make a change to some
code.
| Then we always click Save to save the code.
| Or you can do it in the reverse order.
|
|
| Jeanette Cunningham MS Access MVP -- Melbourne Victoria Australia
|
|
| ".Len B" wrote in message
| ...
| I hadn't done a decompile before so I didn't know what to expect.
| It appears similar to a Compact but when I open the VB code,
| Clicking Debug shows Compile greyed out. Did the decompie work?
| I did it twice.
|
| In any case, I can still save an unvalidated detail record.
|
| --
| Len
| __________________________________________________ ____
| remove nothing for valid email address.



  #14  
Old February 10th, 2010, 11:15 AM posted to microsoft.public.access.forms
.Len B
external usenet poster
 
Posts: 81
Default BeforeUpdate doesn't always fire

No. It doesn't fire.

I have breakpoints everywhere trying to figure where its going.
That's why I put the breakpoint in txtbox exit event. Code window
opens and I single step through.

The txtbox's exit fires, the subform control's exit event fires
and then the click event of a cmd button on the main form fires.
Record is now saved. Subform was certainly dirty.

I cannot click on a txtbox or cbo of main form. They are all locked.

I should say that no fields are 'required' at the table level;
validation intended to happen in BeforeUpdate code.
--
Len
__________________________________________________ ____
remove nothing for valid email address.
"Jeanette Cunningham" wrote in message
...
|I haven't come across this situation before.
| If you set a break point on the subform's before update event in the
code
| window,
| open the form in normal view,
| do enough data entry to make the subform dirty and leave a required
field
| empty,
| then click back on the main form,
| does the code window open and allow you to step through the before
update
| event for the subform?
|
|
| Jeanette Cunningham MS Access MVP -- Melbourne Victoria Australia
|
|
| ".Len B" wrote in message
| ...
| I'm sorry Jeanette, you've lost me.
| I have a main form, frmEnterNotes containing a subform control
| called subfrmNote.
|
| Inside the subfrmNote control is the subform called subfrmNoteNow.
|
| subfrmNoteNow has the BeforeUpdate event where my posted validation
| code lives. This code runs fine if I deliberately try to save the
| detail record from within the subform using cmdSave. The record is
| validated, saved and a new blank record is presented ready to enter
| another note for this parent record.
| It is only if I do not complete the subform normally that the problem
| arises. Example, If I do anything outside the subform, the validation
| code is somehow bypassed and the record is saved regardless of its
| validity.
|
| I think what you are saying is what I am doing. If not please say
| what I should do. I only used the Exit event to provide somewhere
| to put a DoEvents to set a breakpoint. That will go; no point to it.
|
| --
| Len
| __________________________________________________ ____
| remove nothing for valid email address.
| "Jeanette Cunningham" wrote in
message
| ...
| | Ah Hah! Use the before update event on the form that you put inside
the
| | subform control.
| | This explains the strange results you were getting.
| | It's not the subform control where you validate data, it's the form
| | (subform) inside the subform control.
| | Sometimes both the subform and the subform control have the same
name,
| | sometimes they don't.
| |
| | By the way, it's best not to use exit events of controls to
validate
| data -
| | causes problems and is best avoided.
| |
| |
| | Jeanette Cunningham MS Access MVP -- Melbourne Victoria Australia
|
|
|
|
|



 




Thread Tools
Display Modes

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

vB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Forum Jump


All times are GMT +1. The time now is 08:35 PM.


Powered by vBulletin® Version 3.6.4
Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 OfficeFrustration.
The comments are property of their posters.