By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
435,434 Members | 2,994 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 435,434 IT Pros & Developers. It's quick & easy.

Prevent Event From Triggering?

P: n/a
I have a bound listbox control on one of my forms that has an
associated afterupdate event. When this event is invoked, I lock the
control to prevent the user from clicking on it more than once.
However, it appears that Access is queuing the mouse clicks and
calling the afterupdate event regardless of whether the control is
locked or not. If I click the mouse quickly, Access generates the
following error message: "The macro or function set to the
BeforeUpdate or ValidationRule property for this field is preventing
myProgram from saving the data in the field." Is there any way to
prevent this from happening? Thanks.

Vincent

Apr 11 '07 #1
Share this Question
Share on Google+
5 Replies


P: n/a
If the event is being triggered again before the previous one completes, you
may be able avoid it with a static variable that keeps track of whether the
code is already running.

This kind of thing:

Private Sub List2_AfterUpdate()
On Error Goto Err_Hander:
Static bRunning As Boolean

'Jump straight out if this code is already executing.
If bRunning Then Exit Sub

'Flag it as executing.
bRunning = True

'Put your code here.
Exit_Handler
'Flag it as no longer executing.
bRunning = False
Exit Sub

Err_Handler:
MsgBox Err.Description
Resume Exit_Handler
End Sub

This technique is useful where your code contains a DoEvents. If it doesn't,
Access should not re-enter the procedure before it completes.

--
Allen Browne - Microsoft MVP. Perth, Western Australia
Tips for Access users - http://allenbrowne.com/tips.html
Reply to group, rather than allenbrowne at mvps dot org.

"Vincent" <an**********@verizon.netwrote in message
news:11**********************@e65g2000hsc.googlegr oups.com...
>I have a bound listbox control on one of my forms that has an
associated afterupdate event. When this event is invoked, I lock the
control to prevent the user from clicking on it more than once.
However, it appears that Access is queuing the mouse clicks and
calling the afterupdate event regardless of whether the control is
locked or not. If I click the mouse quickly, Access generates the
following error message: "The macro or function set to the
BeforeUpdate or ValidationRule property for this field is preventing
myProgram from saving the data in the field." Is there any way to
prevent this from happening? Thanks.

Vincent
Apr 12 '07 #2

P: n/a
On Apr 11, 8:59 pm, "Allen Browne" <AllenBro...@SeeSig.Invalidwrote:
If the event is being triggered again before the previous one completes, you
may be able avoid it with a static variable that keeps track of whether the
code is already running.

This kind of thing:

Private Sub List2_AfterUpdate()
On Error Goto Err_Hander:
Static bRunning As Boolean

'Jump straight out if this code is already executing.
If bRunning Then Exit Sub

'Flag it as executing.
bRunning = True

'Put your code here.

Exit_Handler
'Flag it as no longer executing.
bRunning = False
Exit Sub

Err_Handler:
MsgBox Err.Description
Resume Exit_Handler
End Sub

This technique is useful where your code contains a DoEvents. If it doesn't,
Access should not re-enter the procedure before it completes.

--
Allen Browne - Microsoft MVP. Perth, Western Australia
Tips for Access users -http://allenbrowne.com/tips.html
Reply to group, rather than allenbrowne at mvps dot org.

"Vincent" <animedrea...@verizon.netwrote in message

news:11**********************@e65g2000hsc.googlegr oups.com...
I have a bound listbox control on one of my forms that has an
associated afterupdate event. When this event is invoked, I lock the
control to prevent the user from clicking on it more than once.
However, it appears that Access is queuing the mouse clicks and
calling the afterupdate event regardless of whether the control is
locked or not. If I click the mouse quickly, Access generates the
following error message: "The macro or function set to the
BeforeUpdate or ValidationRule property for this field is preventing
myProgram from saving the data in the field." Is there any way to
prevent this from happening? Thanks.
Vincent- Hide quoted text -

- Show quoted text -
Allen,

I tried your suggestion, but it's a no go. I still receive the
same error on multiple, consecutive mouse clicks.

Vincent

Apr 12 '07 #3

P: n/a
Okay, I guess I'm not really sure what's going on here.

You have code in the AfterUpdate event of the bound list box.

If you click quickly (double-click?), Access is complaining that there is
something preventing it from saving the data in the field, and it
specifically mentions the BeforeUpdate or Validation Rule.

Is there anything in the control's BeforeUpdate event?
Anything in its Validation Rule?
Anything in its Validation Rule of the field it is bound to in its table?
Are you changing the value of the list box in its AfterUpdate event?

I am trying to understand what that message means.

--
Allen Browne - Microsoft MVP. Perth, Western Australia
Tips for Access users - http://allenbrowne.com/tips.html
Reply to group, rather than allenbrowne at mvps dot org.

"Vincent" <an**********@verizon.netwrote in message
news:11**********************@n76g2000hsh.googlegr oups.com...
On Apr 11, 8:59 pm, "Allen Browne" <AllenBro...@SeeSig.Invalidwrote:
>If the event is being triggered again before the previous one completes,
you
may be able avoid it with a static variable that keeps track of whether
the
code is already running.

This kind of thing:

Private Sub List2_AfterUpdate()
On Error Goto Err_Hander:
Static bRunning As Boolean

'Jump straight out if this code is already executing.
If bRunning Then Exit Sub

'Flag it as executing.
bRunning = True

'Put your code here.

Exit_Handler
'Flag it as no longer executing.
bRunning = False
Exit Sub

Err_Handler:
MsgBox Err.Description
Resume Exit_Handler
End Sub

This technique is useful where your code contains a DoEvents. If it
doesn't,
Access should not re-enter the procedure before it completes.

"Vincent" <animedrea...@verizon.netwrote in message

news:11**********************@e65g2000hsc.googleg roups.com...
>I have a bound listbox control on one of my forms that has an
associated afterupdate event. When this event is invoked, I lock the
control to prevent the user from clicking on it more than once.
However, it appears that Access is queuing the mouse clicks and
calling the afterupdate event regardless of whether the control is
locked or not. If I click the mouse quickly, Access generates the
following error message: "The macro or function set to the
BeforeUpdate or ValidationRule property for this field is preventing
myProgram from saving the data in the field." Is there any way to
prevent this from happening? Thanks.
Vincent- Hide quoted text -

- Show quoted text -

Allen,

I tried your suggestion, but it's a no go. I still receive the
same error on multiple, consecutive mouse clicks.

Vincent
Apr 12 '07 #4

P: n/a
On Apr 12, 8:36 am, "Allen Browne" <AllenBro...@SeeSig.Invalidwrote:
Okay, I guess I'm not really sure what's going on here.

You have code in the AfterUpdate event of the bound list box.

If you click quickly (double-click?), Access is complaining that there is
something preventing it from saving the data in the field, and it
specifically mentions the BeforeUpdate or Validation Rule.

Is there anything in the control's BeforeUpdate event?
Anything in its Validation Rule?
Anything in its Validation Rule of the field it is bound to in its table?
Are you changing the value of the list box in its AfterUpdate event?

I am trying to understand what that message means.

--
Allen Browne - Microsoft MVP. Perth, Western Australia
Tips for Access users -http://allenbrowne.com/tips.html
Reply to group, rather than allenbrowne at mvps dot org.
Allen,

The answer is no to all of your questions. Perhaps I should try
unbinding this control?

Vincent

Apr 12 '07 #5

P: n/a
Try.

Or add:
Debug.Print "Listbox_AfterUpdate fired at " & Now()
as the first line of the procedure, so you can at least verify that it is
this event that is triggering the msg.

--
Allen Browne - Microsoft MVP. Perth, Western Australia
Tips for Access users - http://allenbrowne.com/tips.html
Reply to group, rather than allenbrowne at mvps dot org.

"Vincent" <an**********@verizon.netwrote in message
news:11**********************@n59g2000hsh.googlegr oups.com...
On Apr 12, 8:36 am, "Allen Browne" <AllenBro...@SeeSig.Invalidwrote:
>Okay, I guess I'm not really sure what's going on here.

You have code in the AfterUpdate event of the bound list box.

If you click quickly (double-click?), Access is complaining that there is
something preventing it from saving the data in the field, and it
specifically mentions the BeforeUpdate or Validation Rule.

Is there anything in the control's BeforeUpdate event?
Anything in its Validation Rule?
Anything in its Validation Rule of the field it is bound to in its table?
Are you changing the value of the list box in its AfterUpdate event?

I am trying to understand what that message means.

--
Allen Browne - Microsoft MVP. Perth, Western Australia
Tips for Access users -http://allenbrowne.com/tips.html
Reply to group, rather than allenbrowne at mvps dot org.

Allen,

The answer is no to all of your questions. Perhaps I should try
unbinding this control?

Vincent
Apr 12 '07 #6

This discussion thread is closed

Replies have been disabled for this discussion.