Help | Site Map
Connecting Tech Pros Worldwide
 
 
LinkBack Thread Tools
  #1  
Old April 12th, 2007, 12:15 AM
Vincent
Guest
 
Posts: n/a
Default Prevent Event From Triggering?

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

  #2  
Old April 12th, 2007, 02:05 AM
Allen Browne
Guest
 
Posts: n/a
Default Re: Prevent Event From Triggering?

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" <animedreamer@verizon.netwrote in message
news:1176332753.783892.150220@e65g2000hsc.googlegr oups.com...
Quote:
>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
  #3  
Old April 12th, 2007, 01:05 PM
Vincent
Guest
 
Posts: n/a
Default Re: Prevent Event From Triggering?

On Apr 11, 8:59 pm, "Allen Browne" <AllenBro...@SeeSig.Invalidwrote:
Quote:
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:1176332753.783892.150220@e65g2000hsc.googlegr oups.com...
>
>
>
Quote:
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.
>
Quote:
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

  #4  
Old April 12th, 2007, 01:45 PM
Allen Browne
Guest
 
Posts: n/a
Default Re: Prevent Event From Triggering?

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" <animedreamer@verizon.netwrote in message
news:1176378933.217751.250230@n76g2000hsh.googlegr oups.com...
Quote:
On Apr 11, 8:59 pm, "Allen Browne" <AllenBro...@SeeSig.Invalidwrote:
Quote:
>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:1176332753.783892.150220@e65g2000hsc.googleg roups.com...
>>
>>
>>
Quote:
>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.
>>
Quote:
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
  #5  
Old April 12th, 2007, 03:25 PM
Vincent
Guest
 
Posts: n/a
Default Re: Prevent Event From Triggering?

On Apr 12, 8:36 am, "Allen Browne" <AllenBro...@SeeSig.Invalidwrote:
Quote:
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

  #6  
Old April 12th, 2007, 04:25 PM
Allen Browne
Guest
 
Posts: n/a
Default Re: Prevent Event From Triggering?

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" <animedreamer@verizon.netwrote in message
news:1176387547.095852.260410@n59g2000hsh.googlegr oups.com...
Quote:
On Apr 12, 8:36 am, "Allen Browne" <AllenBro...@SeeSig.Invalidwrote:
Quote:
>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
>
 

Bookmarks

Thread Tools

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 Off
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On

What is Bytes?

We are a network of experts and professionals in IT and software development that help one another with answers to tough questions and share insights. Get the best answers to your questions from over network members.
Post your question now . . .
It's fast and it's free

Popular Articles