View Single Post
Old 02-19-2018, 03:41 AM   #1
Newly Registered User
Join Date: Nov 2013
Posts: 140
Thanks: 33
Thanked 0 Times in 0 Posts
helmerr is on a distinguished road
Error handling docmd.runcommand

I'm attaching a sample of a database I've been having some minor issues with. While the form and buttons work, I'd like to work out one final bug:

The sample DB consists of three forms: one main form and two subs; one of which is continuous. Both forms use bound text and comboboxes.

The combination of forms is used to add new records from the top form (frmStaffMXHeader), as well as edit existing records from the continuous form (frmStaffMXDetail) by selecting any record from the continuous form in the detail section. When records are selected from the detail/continuous form, they are populated to the top form for editing using some bookmark code.

When the user clicks the cmdReset icon (or cmdNew), the commands docmd.runcommand acCmdUndo and acNewRec are run in order to clear the top form and prepare it for a new record entry, which is also the default when the form loads.

The issue I'm having is when the user clicks cmdReset, prior to any data being entered in the blank new record, it triggers the error below. Please note, I've tried using IF statements to check and only run if the textbox controls have been entered prior to clicking this button, as well as checking for me.dirty but I have been unsuccessful. (Perhaps something was wrong with my code). For icing on the cake, if Its possible to undo all controls at once in the header form, that'd be perfect. Please help, thank you.

Run-time error '2046'
The command or action 'Undo' isn't available now.
Attached Files
File Type: accdb Database2.accdb (832.0 KB, 34 views)

helmerr is offline   Reply With Quote