472,780 Members | 1,792 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 472,780 software developers and data experts.

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 9880
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
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
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
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
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
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
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
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
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
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...
3
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 2 August 2023 starting at 18:00 UK time (6PM UTC+1) and finishing at about 19:15 (7.15PM) The start time is equivalent to 19:00 (7PM) in Central...
0
by: erikbower65 | last post by:
Using CodiumAI's pr-agent is simple and powerful. Follow these steps: 1. Install CodiumAI CLI: Ensure Node.js is installed, then run 'npm install -g codiumai' in the terminal. 2. Connect to...
0
linyimin
by: linyimin | last post by:
Spring Startup Analyzer generates an interactive Spring application startup report that lets you understand what contributes to the application startup time and helps to optimize it. Support for...
0
by: erikbower65 | last post by:
Here's a concise step-by-step guide for manually installing IntelliJ IDEA: 1. Download: Visit the official JetBrains website and download the IntelliJ IDEA Community or Ultimate edition based on...
0
by: kcodez | last post by:
As a H5 game development enthusiast, I recently wrote a very interesting little game - Toy Claw ((http://claw.kjeek.com/))。Here I will summarize and share the development experience here, and hope it...
0
by: Taofi | last post by:
I try to insert a new record but the error message says the number of query names and destination fields are not the same This are my field names ID, Budgeted, Actual, Status and Differences ...
14
DJRhino1175
by: DJRhino1175 | last post by:
When I run this code I get an error, its Run-time error# 424 Object required...This is my first attempt at doing something like this. I test the entire code and it worked until I added this - If...
0
by: Mushico | last post by:
How to calculate date of retirement from date of birth
2
by: DJRhino | last post by:
Was curious if anyone else was having this same issue or not.... I was just Up/Down graded to windows 11 and now my access combo boxes are not acting right. With win 10 I could start typing...

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.