Can anyone explain this error. I have the following code in a button on a form -
-
Private Sub cmdExit_Click()
-
-
DoCmd.Close acForm, "ActivityMaintenance"
-
-
-
End Sub
-
It's my standard exit button code & I have never had problems with it before.
Now in one form it intermittently comes up with the error 2585 "This action canot be carried out while processing a form or report event.
I have researched this error on this forum & on the web an in all cases it is claimed that there is a procedure in the forms Activate or Open events that cause this.
I have removed any such code but this does not fix the problem.
The error seems to occur after a combobox click event triggers a complex update of quite a few records which causes a delay in responding to the on click event in the exit button. Howerver this code runs synchronously & therefore should be comleted before the exit button click event is activiated.
Is there any way of tracking the actual event that access is complaining about ??
19 27070
I have sort of solved the problem by changing the code to; -
Private Sub cmdExit_Click()
-
-
On Error Resume Next
-
DoCmd.Close acForm, "ActivityMaintenance"
-
-
-
End Sub
-
so now if the error occus it simply appears as if the button click did't work and a second button click seems to close the form OK.
However it is a clunky fix & I would really like to know what is happening
On Error Resume Next simply hides the error
If the update is running, or some other process related to that form, is running, u could wait for it to complete
try putting a DoEvents or DBEngine.Idle in
e.g.
Private Sub cmdExit_Click()
DoEvents
DoCmd.Close acForm, "ActivityMaintenance"
End Sub
or
Private Sub cmdExit_Click()
DBEngine.Idle
DoCmd.Close acForm, "ActivityMaintenance"
End Sub
if closing current form, have u just tried doing this
DoCmd.Close
Can anyone explain this error. I have the following code in a button on a form -
-
Private Sub cmdExit_Click()
-
-
DoCmd.Close acForm, "ActivityMaintenance"
-
-
-
End Sub
-
It's my standard exit button code & I have never had problems with it before.
Now in one form it intermittently comes up with the error 2585 "This action canot be carried out while processing a form or report event.
I have researched this error on this forum & on the web an in all cases it is claimed that there is a procedure in the forms Activate or Open events that cause this.
I have removed any such code but this does not fix the problem.
The error seems to occur after a combobox click event triggers a complex update of quite a few records which causes a delay in responding to the on click event in the exit button. Howerver this code runs synchronously & therefore should be comleted before the exit button click event is activiated.
Is there any way of tracking the actual event that access is complaining about ??
After the Update in the combo click events put a
DoEvents
command, this should process this procedure before anything else can happen.
After the Update in the combo click events put a DoEvents command, this should process this procedure before anything else can happen.
Another possibility (based on VB6, but might work) - after hitting the error, tell the debugger to step. If it works anything like VB6, you may find it stops at the next statement in whatever is executing.
Putting in a doevents command doesnt work, i still get the error
TTrying to step throught the debugger also doesn't work , just repeats the error.
Also waiting a time before executing doesn't work - ie I have a standard routing for pausing the program while allowing processes to finish - this is the code -
-
private sub cmdExit_Click()
-
-
TimeDelay 5,true
-
Docmd.close acform,"ActivityMaintenance"
-
-
End Sub
-
-
Public Function TimeDelay(Secs As Integer, ByVal AllowEvents As Boolean)
-
-
' Puts a delay of the number of seconds into the processing
-
Dim dStart As Date
-
-
If Secs < 1 Then
-
Exit Function
-
End If
-
dStart = Now
-
Do Until DateDiff("s", dStart, Now) > Secs
-
If AllowEvents Then
-
DoEvents
-
End If
-
Loop
-
-
'
-
End Function
-
...TTrying to step throught the debugger also doesn't work , just repeats the error.
Hm...
Could you debug when the error occurs, comment out your action whichi is producing it, then hit the Step key. If it's executing something elsewhere in your code, maybe this will stop at the next statement. If it doesn't reset the execution, that is.
Just a possibility...
Andrew
I meant to put the DoEvents in the procedure that's still running when the form is trying to close.
There is no error in the code to close the form it is simply that you cannot close a form while any procedure behind that form is still running. Procedures written behind a form in a form class module depend on the form being open. The error is occuring because you are trying to close a form that still has a procedure running.
I was suggesting that you throw a few Do Events into the aforementioned procedure to see if that would expedite the procedure to allow the form to close. No procedure should be taking this long to process.
Mary
Putting in a doevents command doesnt work, i still get the error
TTrying to step throught the debugger also doesn't work , just repeats the error.
Also waiting a time before executing doesn't work - ie I have a standard routing for pausing the program while allowing processes to finish - this is the code -
-
private sub cmdExit_Click()
-
-
TimeDelay 5,true
-
Docmd.close acform,"ActivityMaintenance"
-
-
End Sub
-
-
Public Function TimeDelay(Secs As Integer, ByVal AllowEvents As Boolean)
-
-
' Puts a delay of the number of seconds into the processing
-
Dim dStart As Date
-
-
If Secs < 1 Then
-
Exit Function
-
End If
-
dStart = Now
-
Do Until DateDiff("s", dStart, Now) > Secs
-
If AllowEvents Then
-
DoEvents
-
End If
-
Loop
-
-
'
-
End Function
-
Mary
I put a doevents at the end of every sub & function and exit sub & exit function in the entire project. The error still occurs.
On researching the actual functioning of the doevents command I found out that it hands control back to the processor to clear its event queue from all sources before returning the control back to the calling routine.
This would imply that one doevents at any point in any program should let all pending processes complete, so the the suggestion to use a doevents call was a good one, it just didn't work.
does anyone know if events are triggered asynchroously or synchonously, ie when an event is triggered the triggering process halts until the triggered event processing ends or opens a new thread for the event process to process independantly of the calling process ?. If the event are asynchronous then this would explain the problem, but to resolve it I need some way of detecting what events are processing before I try to close the form.
Any suggestions ?
Killer42,
I tried your suggestion but the debugger merely stepped through remaining code in the procedure, though I did cut & paste the offending line into the immediate window & tried to execute it at several points later in the program. It still produced the error.
does anyone know if events are triggered asynchroously or synchonously, ie when an event is triggered the triggering process halts until the triggered event processing ends or opens a new thread for the event process to process independantly of the calling process ?. If the event are asynchronous then this would explain the problem, but to resolve it I need some way of detecting what events are processing before I try to close the form.
Any suggestions ?
To the best of my knowledge events are triggered and completed asynchonously.
One thing you could try is to put an unbound label on the form. You will have to default the caption to something " " will do. I've called it lblProcess.
Then at the beginning of each event put
Me.lblProcess.Caption = "Running: Description of Event"
At the end of each event put
Me.lblProcess.Caption = "Complete: Description of Event"
You could use a different textbox for each event for better control.
Most of them should change almost immediately to Complete
Mary
Ahhh!!
The penny is dropping, but slowly
The events are asynchronous, but the code in them executes until it issues an I/O call and relinquishes control to to another thread.
Subsequently most events will appear synchronous which explains why my code has worked before. Not only that but since clicking the exit button involves moving the mouse to the button before clicking there is usually at least 1 seconds delay between any previous event call and the click event, an eternity in computer terms.
However, because one my processes involves looping through and updating several hundred records, each I/O of which yields control to antoher thread, then it is possible that the click event can attempt to execute before the previous event proceure has completed.
I will try to resolve this with the following routine -
-
-
Public Type RunningProcess
-
IsRunning As Boolean
-
ProcessName As String
-
End Type
-
-
Global Processes(500) As RunningProcess
-
-
Function SetReleaseProcess(ByRef SetUnset As Boolean, ByRef ProcessNo As Integer, ByRef ProcessName As String) As Boolean
-
-
' Sets a flag when a precess starts and releases it when it exits. Returns True if there is an available flag to set, otherwise false if too many processes are running
-
' SetUnset is the state of the flag to be set
-
' ProcessNo points to the elemet in the array owned by the process. Returned to the call process when setting a flag, provided by the calling process when releasing a flag
-
' ProcessName - the name of the process settin or onsetting the flag.
-
' txtBox points to a textbox where the running processes can be listed. Will be "" when no proceses are running
-
-
Dim cnt As Integer
-
Dim Runningtxt As String
-
Select Case SetUnset
-
Case True
-
For cnt = 0 To 99
-
If Processes(cnt).IsRunning = False Then
-
Processes(cnt).IsRunning = True
-
ProcessNo = cnt
-
Processes(cnt).ProcessName = ProcessName
-
SetReleaseProcess = True
-
Exit For
-
End If
-
SetReleaseProcess = False
-
Next cnt
-
Case False
-
Processes(ProcessNo).IsRunning = False
-
Processes(ProcessNo).ProcessName = ""
-
SetReleaseProcess = True
-
End Select
-
-
Runningtxt = ""
-
For cnt = 0 To 499
-
If Processes(cnt).IsRunning = True Then
-
If Len(Runningtxt) > 0 Then Runningtxt = Runningtxt & Chr(10)
-
Runningtxt = ProcessName & " running"
-
End If
-
Next cnt
-
TxtBox = Runningtxt
-
-
End Function
-
-
I'll let you know if this works. It also allows me to set a textbox with all running proceses for the user to look at while the program waits for them to finish. I will also hide the exit button until all processes have completed
Just a cosmetic thing - you have a typo in your comments - ' Sets a flag when a precess starts ...
Thanks for noticing the typo Killer
The code works a treat. It immediately showed a recursion in one of the processes I wasn't aware of.
It also prevents the exit button from being pressed while processes are in progress and gives the user feedback on the processes that are triggered as they chgange the data on the form.
I'll use this as a standard in future where I have complex interactions with the user and the database.
NeoPa 32,556
Expert Mod 16PB
Result Andrew!
This also helps those of us who've followed the thread.
Another error in the code. The first cnt loop has a limit of 99. It should be 499. I made the array large because I suspected that there may be recursive calls and I wanted to see how deep the recursion went.
Another error in the code. The first cnt loop has a limit of 99. It should be 499. I made the array large because I suspected that there may be recursive calls and I wanted to see how deep the recursion went.
You mean I missed a bug? Boy, is my face red! :)
In my defense, I didn't actually read the code. Just glanced at the comments.
I actually ran into this error for the first time when I was trying to close a form while a class module function was changing the page on a tab control. Solved it by simply saving a boolean that it should close and check for it's value after the tabpage change function took place. Perhaps someone who didnt think of this obvious solution like me in the first place may find use of this tip.
NeoPa 32,556
Expert Mod 16PB
We often have members, and other public users, who go through threads looking for answers. This includes many threads that haven't been actively updated for years, but that doesn't mean they're not still in use.
Thanks for posting & Welcome to Bytes!
I had a very similar problem to the one in the original post, and Killer42's suggestion above was very helpful. I stepped through my VBA code (MS Access 2007) to find the buggy code I needed to delete and that was causing the close action to fail. Thank you so much! This bug had been sitting in my code for years. I had previously put a band-aid on it until this morning when a user told me the application was crashing when they tried to open it.
hi
i had this error same and it is very simple in end of vba window had somthing note please delete them retype your code and ...
Sign in to post your reply or Sign up for a free account.
Similar topics
by: Abhijit Bhadra |
last post by:
Hi ,
I was trying to build my project in VC with latest Service Packs but
got this error .
C:\Program Files\Microsoft Visual
Studio\VC98\ATL\INCLUDE\atlconv.h(125) : error C2440: 'return' :...
|
by: Tom Bray |
last post by:
Ok I am baffled I can not figure out this problem. I am getting the
following error:
Portal Error - A DropDownList cannot have multiple items selected.
Error information
Name Value
Message...
|
by: Simon Harris |
last post by:
I have created a web service, which when I call in my browser presents the
text form etc. When I click the button, I get this error:
System.ArgumentException: Cannot convert to System.Int32....
|
by: kaizen |
last post by:
Hi,
i wrote the code in C and compiled in VC++ compiler. at that time it
has thrown the below mentioned error.
error C2664: 'strcpy' : cannot convert parameter 2 from 'char' to
'const char *'...
|
by: Adrian Turner |
last post by:
I am just starting developing with .Net(Have used asp for years). I have
created a very simple upload page which once uploaded opens the file(excel)
and displays the data. If I Attempt to re-run...
|
by: Jean Stachler |
last post by:
We have a VB app that is set off automatically when a file exists in a certain directory. The file contains a listing of part numbers which the program reads and than retrieves drawings which are in...
|
by: td0g03 |
last post by:
I have no idea why am I getting an error C2664: 'parseInput' : cannot convert parameter 2 from 'main::WORD_STRUCT ' to 'struct WORD_STRUCT '
#include <stdio.h>
#include <stdlib.h>
#include...
|
by: slizorn |
last post by:
well the error i get is the title above:
error C2664: 'searchTree' : cannot convert parameter 2 from 'const char *' to 'char'
error is form this line
searchTree(treeObj->root ,data1.c_str());...
|
by: emmanuelkatto |
last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud.
Please let me know.
Thanks!
Emmanuel
|
by: BarryA |
last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
|
by: nemocccc |
last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
|
by: Hystou |
last post by:
There are some requirements for setting up RAID:
1. The motherboard and BIOS support RAID configuration.
2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
|
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,...
|
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...
|
by: Hystou |
last post by:
Overview:
Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
|
by: tracyyun |
last post by:
Dear forum friends,
With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
|
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...
| |