Solved The command or Action "OnError" isn't available now ... (2 Viewers)

Local time
Today, 03:13
Joined
Feb 28, 2023
Messages
628
Lately, I've been getting the following message when I save my front end as an .accde. The error points to my autoexec macro - which only contains two lines:
OnError - GoTo Fail
RunCode AutoExec()

The second line runs the AutoExec function in my VBA module.

After I click okay, I get a pop-up that says Macro Single Step pointing to Macro Name: AutoExec, Action Name: OnError, Arguments: "2," <with the comma, without the quotes>, Error Number: 2046, and a button for "Stop All Macros". The buttons for Step and Continue are grayed out.

The .accde seems to be created and works fine, but I wasn't sure if it was safe to ignore this error and what might be causing it.

It's a fairly new error (to me), but I recently made a lot of changes to the front end (switchboard form, hiding the toolbars, hiding the nave pane, hiding the interface on loading, etc.)

My pre-release procedure is typically:
  • Open the database with the decompile switch.
  • Do a Compact and Repair with the shift-key bypass.
  • Open VBE and compile.
  • Do two more C&R's with the shift-key bypass.
  • Save as .accde.
However, I found that I also get the error if I close the database after the final C&R, open it without holding the shift key, and save as an .accde. (Actually, I seem to get the error any time I save the database as an .accde.)

Thanks in advance!!!
 
Local time
Today, 03:13
Joined
Feb 28, 2023
Messages
628
More info - I opened a copy of a month-old .accdb file and saved it as an .accde and I did NOT get the error message, even though it contains the same autoexec macro. I didn't try the decompile, C&R etc. steps on it, though ...

Update - Tested with the decompile and C&R on the older database and still did not get the error.
 
Last edited:
Local time
Today, 03:13
Joined
Feb 28, 2023
Messages
628
Oddly, it was related. I changed the database to load my switchboard form on startup and I no longer see the error.
 

tvanstiphout

Active member
Local time
Today, 00:13
Joined
Jan 22, 2016
Messages
222
Open the good macro in the designer. Ctrl+A to select all. Ctrl+C to copy. Paste into notepad and save as 1.xml.
Repeat for the bad macro and save as 2.xml.
Compare.
Let us know what you find.

P.S. My AutoExec macro only has 1 line: RunCode to run the startup function.
 
Local time
Today, 03:13
Joined
Feb 28, 2023
Messages
628
P.S. My AutoExec macro only has 1 line: RunCode to run the startup function.
Mine only had that and the OnError line.

Based on comments in the other thread above, I'm removing the AutoExec macro and calling the startup function from the load event of the startup form.

But in theory they should work the same way.

Will post compare results soon, but the macros SHOULDN'T have changed.
 
Local time
Today, 03:13
Joined
Feb 28, 2023
Messages
628
No differences between 1.xml and 2.xml according to the Beyond Compare program.

Good suggestion (although I'm pretty happy to get rid of the AutoExec macro. The only macros I have now are things that I need to run from the command line.
 

Users who are viewing this thread

Top Bottom