473,486 Members | 1,953 Online
Bytes | Software Development & Data Engineering Community
Create Post

Home Posts Topics Members FAQ

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

Apr 11 '07 #1
5 9968
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
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
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
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
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 thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
2500
by: Jerry | last post by:
Hi All, How can I prevent a script from running when a previous instance of the script had already been triggered and the script is running in the background already? So, even when a script is...
1
3821
by: Wavemaker | last post by:
I was wondering if there is a way to change the value of a control without triggering an event. The ComboBox control, for example, will trigger the SelectedIndexChanged event when its SelectedIndex...
5
3102
by: Frank Rizzo | last post by:
Hello, I have a dozen 3rd party controls on my form. I am trying to detect when the application is idle. But even after the mouse and the keyboard are no longer moving, something is still...
6
1922
by: Lloyd Dupont | last post by:
I have a web form with multiple part. I do want the user to click the submit button to post back, so I know which functionality was triggered. unfortunately, when the focus is any text box, if...
8
2337
by: Steve Schroeder | last post by:
For some reason I cannot get the OnSelectedIndexChanged event to fire for a listbox I have on a page. I'm able to populate the listbox with data from a stored procedure, but cannot trigger the...
2
1425
by: serge calderara | last post by:
Dear all, On a web page I have a series of Textbox object. All of them have PostBack=false. When I click on Submit button, only the TextBox_changed event of the first object is trigged not...
7
1623
by: christinamasalha | last post by:
hello all, I've been trying to figure this out for days but i don't know what the problem is. I have this form which contains 2 subforms on it. On one of the subforms there is a fields called...
0
1987
by: BillCo | last post by:
I'm a C# Newbie, so if I've missed the obvious here go easy!!! I have a form opened from a MDI parent. The form has a data bound combo box, with a SelectedIndexChanged event (fills a list view...
13
8596
by: mirandacascade | last post by:
I want to set things up such that a section of code will have been executed by the time one clicks on the drop down arrow on a combo box control. Currently, that section of code resides in the...
0
7094
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
6964
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
7123
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
7173
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
1
4863
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...
0
4559
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...
0
3066
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The...
0
3070
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
0
1378
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated ...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.