Error 2585 (1 Viewer)

Snowflake68

Registered User.
Local time
Today, 14:57
Joined
May 28, 2014
Messages
452
I have a text box on a form with a OnClick event that opens a form using a where condition.

If the user double clicks instead of single click they get the error "This action can't be carried out while processing a form or report event"

How can I prevent the Error 2585 if a user double clicks?

I have tried to set the double click event to Cancel = True but this does not stop the error.

Code:
Private Sub txtCustomerPriceGroup_DblClick(Cancel As Integer)
    Cancel = True
End Sub

I have also added a error handler to the OnClick event to StopAllMacros (yes its a macro so I should change this to VBA) but that is not trapping the error either.
 

static

Registered User.
Local time
Today, 14:57
Joined
Nov 2, 2015
Messages
823
The event isn't doing anything. Remove it.

You really shouldn't be using click events on text boxes. As said in your other thread, that's what buttons are for.
 

Snowflake68

Registered User.
Local time
Today, 14:57
Joined
May 28, 2014
Messages
452
The event isn't doing anything. Remove it.

You really shouldn't be using click events on text boxes. As said in your other thread, that's what buttons are for.

The text box is bound to a table so the value in the box changes for each customer so clicking on it opens up a report relevant to that customer code so a command button in this instance is not what I want. The text box works well but I may just end up changing it to a double click event, at least then it wont error.
 

static

Registered User.
Local time
Today, 14:57
Joined
Nov 2, 2015
Messages
823
Well, your doubleclick event isn't doing anything so the error is either in the click event or your form is corrupt.

You also need to look at the actual doubleclick property for the control. If doesn't say [event procedure] and isn't blank it's probably running some other macro not the code you posted.
 

Snowflake68

Registered User.
Local time
Today, 14:57
Joined
May 28, 2014
Messages
452
Well, your doubleclick event isn't doing anything so the error is either in the click event or your form is corrupt.

You also need to look at the actual doubleclick property for the control. If doesn't say [event procedure] and isn't blank it's probably running some other macro not the code you posted.

The error is in the OnClick event, I know that because it produced the error prior to me putting the cancel = true in the OnDoubleClick event. This is what another post suggested I do to try and stop the double click event and that post owner said it worked so I thought I would try it. I only posted that code to show that I had try to deal with trying to stop the double clicking which obviously didnt work so I took it out.

The error trapping i put in on the OnClick event isnt trapping the error so hence my post for help.

I didnt post the code of the macro because its not a simple copy and paste but i have now done a screenshot of the macro. Attached.
 

Attachments

  • OnClickEvent.jpg
    OnClickEvent.jpg
    46 KB · Views: 63

static

Registered User.
Local time
Today, 14:57
Joined
Nov 2, 2015
Messages
823
I see. I've never used macros.

The where condition with 2 equals looks odd.
Naming a form rpt_ looks odd.

If you post the converted vba that might help.

Better yet a stripped copy of the db.
 

isladogs

MVP / VIP
Local time
Today, 14:57
Joined
Jan 14, 2017
Messages
18,216
Agree completely with static.

Think about what will happen if you need to edit the contents of the textbox.
You click in it and before you can edit it, a report opens.
Definitely not a good idea even if you can get it to work.

This is what you need to do

1. Get rid of the macro and use VBA
2. Stop using code or macros which run when you click or double click a textbox. These events are prone to error as two successive posts of yours have shown.
3. Use a command button to open the report filtered to the value in the textbox. This is straightforward and not subject to errors.
 

arnelgp

..forever waiting... waiting for jellybean!
Local time
Today, 21:57
Joined
May 7, 2009
Messages
19,237
Create a Public boolean variable on a module, eg. gIsClicked.

Public gIsClicked As Boolean

now on the Click Event of your textbox, test it's state:

Private Sub text1_Click()
If not gIsClick then
gIsClicked=True
'Open the form
DoCmd.OpenForm ...
End If
End Sub

***
Now on the Close/Unload Event of the form that you opened (on the tbox click event), set the Global flag to False:

Private Sub Form_Unload()
gIsCliked=False
End Sub

***
vba this will work. On macro you need to create an equivalent Tempvars

for macro:

Code:
If IsNull([Tempvars]![gIsClicked])
	SetTempVars
		Name: gIsClicked
		Expression: True
	OpenForm
		Form Name: your form name
End If

now on the Unload event of the form that you opened in the macro,
remove the tempvars:

Public Sub Form_Unload()
Tempvars.Remove "gIsClicked"
End Sub

Edit: mistake I used form but same thing you will do with report
 
Last edited:

Snowflake68

Registered User.
Local time
Today, 14:57
Joined
May 28, 2014
Messages
452
Quick update. I sorted it out and no longer errors when double clicking. The issue was that I had a OnDeactivate event on the popup form to close the form (which wasnt working anyway) so I have now removed the On Deactivate code and made the popup form open up as a dialog to force the user to close it before moving on.

Thanks to everyone for their helpful suggestions. Im still learning and everyday I learn something new from you guys. I do try and use VBA all the time but sometimes its just easier to create a macro but I am going to try and reduce that down going forwards. I am usually up against time and expected to do stuff that I dont know how to do without anyone around me to ask for help apart from you guys so I am very grateful of all the help I can get.

Thanks again.
 

Snowflake68

Registered User.
Local time
Today, 14:57
Joined
May 28, 2014
Messages
452
I see. I've never used macros.

The where condition with 2 equals looks odd.
Naming a form rpt_ looks odd.

If you post the converted vba that might help.

Better yet a stripped copy of the db.

The the pop up form is basically a report to the user but I agree naming this rpt is a mistake on my part.

I am trying not to use macros when I can but I know the where condition works for this one and I use it a fair bit for other applications. I agree it does look odd and its not something I completely understand but it does work.
 

isladogs

MVP / VIP
Local time
Today, 14:57
Joined
Jan 14, 2017
Messages
18,216
Glad you got it working
I still recommend you replace the click events on the textbox with a button.
 

Snowflake68

Registered User.
Local time
Today, 14:57
Joined
May 28, 2014
Messages
452
Create a Public boolean variable on a module, eg. gIsClicked.

Public gIsClicked As Boolean

now on the Click Event of your textbox, test it's state:

Private Sub text1_Click()
If not gIsClick then
gIsClicked=True
'Open the form
DoCmd.OpenForm ...
End If
End Sub

***
Now on the Close/Unload Event of the form that you opened (on the tbox click event), set the Global flag to False:

Private Sub Form_Unload()
gIsCliked=False
End Sub

***
vba this will work. On macro you need to create an equivalent Tempvars

for macro:

Code:
If IsNull([Tempvars]![gIsClicked])
	SetTempVars
		Name: gIsClicked
		Expression: True
	OpenForm
		Form Name: your form name
End If

now on the Unload event of the form that you opened in the macro,
remove the tempvars:

Public Sub Form_Unload()
Tempvars.Remove "gIsClicked"
End Sub

Edit: mistake I used form but same thing you will do with report

I did try your suggestion (VBA version) but it didn't work for me. But I really appreciate you taking the time out to put this together to try and help me.
All working now as per my earlier post today.
Thanks again.
 

Snowflake68

Registered User.
Local time
Today, 14:57
Joined
May 28, 2014
Messages
452
Agree completely with static.

Think about what will happen if you need to edit the contents of the textbox.
You click in it and before you can edit it, a report opens.
Definitely not a good idea even if you can get it to work.

This is what you need to do

1. Get rid of the macro and use VBA
2. Stop using code or macros which run when you click or double click a textbox. These events are prone to error as two successive posts of yours have shown.
3. Use a command button to open the report filtered to the value in the textbox. This is straightforward and not subject to errors.


1. I am trying to stop using macros and will try and use vba when I know how to write what I need to do.
2. I need to continue to use OnClick events as lots of my forms are datasheets which the user clicks on a value to open up another report or form with that value as the criteria.
3. Command buttons are not an option in this instance due to it being a datasheet.

Just to add; the data is locked and is read only so the OnClick event shouldn't be an issue. I agree though that the double click event (as per my other post you mention) is an issue so I need to stay away from those where possible. Although the application in question (on my other post) is not my application so I dont really have much control over that. I have just been asked to help with a couple of things such as the move the cursor to the end of text after double clicking (yet to be resolved).

Thanks again for your help, it is as always very much appreciated.
 

Snowflake68

Registered User.
Local time
Today, 14:57
Joined
May 28, 2014
Messages
452
Glad you got it working
I still recommend you replace the click events on the textbox with a button.

Cant use command buttons when its a datasheet. Events are available on text boxes otherwise whats the point of having them there?
 

Snowflake68

Registered User.
Local time
Today, 14:57
Joined
May 28, 2014
Messages
452
The event isn't doing anything. Remove it.

You really shouldn't be using click events on text boxes. As said in your other thread, that's what buttons are for.

Agree and removed :)
 

Users who are viewing this thread

Top Bottom