ADE error which works fine in ADP

scheeps

Registered User.
Local time
Today, 17:02
Joined
Mar 10, 2011
Messages
82
I've got a functional ADP project which compiles and works seamlessly. But once I save and compile the project as an ADE file the only modal form's save button return the following error:

"The command or action 'Save' isn't available now."

The Save button's code is as follow:

Code:
Private Sub cmdSave_Click()
On Error GoTo Err_cmdSave_Click
    
    DoCmd.RunCommand acCmdSave
    DoCmd.Close
Exit_cmdSave_Click:
    Exit Sub

Err_cmdSave_Click:
    MsgBox Err.Description
    Resume Exit_cmdSave_Click
End Sub

How is this possible? What is different for ADE and ADP to cause such an error out of the blue? Doesn't ADE just make all objects read-only without messing around with functionality?

Is there maybe another way to code the Save button to get past the error in ADE?

Hope you guys will be able to assist to get me past this hurdle.

Thanks
 
You need DoCmd.RunCommand acCmdSaveRecord

acCmdSave is to save design changes and as you know ADEs don't allow design changes. That's why it errors.
 
This kind of thing confuses people all the time! I've never understood why, since they make it explicit with

acCmdSaveRecord

they don't also make it explicit with

acCmdSaveDesign

instead of just

acCmdSave

which is 'unqualified,' as it were!

Linq ;0)>
 
Thanks for the quick responses guys, but I've made the change, saved as ADE but I still get the same error.

Anything else that might cause the error?
 
This kind of thing confuses people all the time! I've never understood why,
Probably because that's the first constant you get when you type acCmdSave and you have to scroll down the list to see acCmdSaveRecord. So perhaps your first reaction would be, "ah, acCmdSave will do because it's got the word 'Save' in it".
 
Can you tell us what the exact error message is? It's a different constant, it can't be exactly the same.
 
I can confirm that the code now looks as follow:

Code:
Private Sub cmdSave_Click()
On Error GoTo Err_cmdSave_Click
    
    DoCmd.RunCommand acCmdSaveRecord
    DoCmd.Close
Exit_cmdSave_Click:
    Exit Sub

Err_cmdSave_Click:
    MsgBox Err.Description
    Resume Exit_cmdSave_Click
End Sub

and if I save as ADE I still get the same error which is "The command or action 'Save' isn't available now."

Nothing really changed accept the 'Record' part which was added on to the constant.
 
Are you sure the error reads

"The command or action 'Save' isn't available now."

Or it reads

"The command or action 'SaveRecord' isn't available now."

?
 
I've put a breakpoint on 'DoCmd.RunCommand acCmdSaveRecord' in the adp project, I then get the

"The command or action 'SaveRecord' isn't available now."

error. If the breakpoint is removed, the code executes without a problem.

But the ADE saved project still gives me the

"The command or action 'Save' isn't available now."

error.

Arrrggh, this is frustrating.
 
Is the Modal Form a Bound Form, i.e. does it actually have a Record Source? We've established that 'Save,' referring to the Form's Design isn't available in an ADE file, but it also isn't available, referring to a Record, on any type of Access Form unless it is Bound to a Record Source. Are you, in fact, trying to 'Save' a Record here?

Linq ;0)>
 
Yes, this modal form does have a record source and I'm trying to Save to the Contacts table.

Is there a way to Save a record from a modal form in ADE?
 
Just a bit of background; the specific form saves a Contact person which is not found in the Contact Person combo box. If the contact is not found, the user double click the combo box and this frmContact modal form appears. User adds the missing contact, hit the Save & Close button and the new added contact appears in the Combo box.
I pass the company id through the OpenArgs parameter to which the contact need to be added to.

What is the Record Source of the form?
The RecordSource for the form is 'ODS.Contact'

I'm pretty flexible on how the missing contact can be added, so if changing the process/logic to get pass the error, I'm more than willing to try that.
 
I wonder if the record has already been saved in some way?

Looking in Google one of the things I came across was that the record couldn't be saved if there is nothing to save. It was in an Archived article from here in fact.

Their solution was to check to see whether the form was Dirty, i.e. had unsaved changes, before attempting to save.


So perhaps something like this ...

Code:
Private Sub cmdSave_Click()
On Error GoTo Err_cmdSave_Click
    
    [B]If Me.Dirty then[/B] DoCmd.RunCommand acCmdSaveRecord
    DoCmd.Close
Exit_cmdSave_Click:
    Exit Sub

Err_cmdSave_Click:
    MsgBox Err.Description
    Resume Exit_cmdSave_Click
End Sub
 
Hi Nigel,
I've made the change according your recommendation but is still get the "The command or action 'Save' isn't available now." error in ADE, in ADP it works 100%.

The fact that it still fails on 'Save' and not 'SaveRecord' indicates that the ADE almost does initialized the 'DoCmd.RunCommand acCmdSaveRecord' code.

I might just create a new form or change the logic a bit to get it going.

Any other suggestions are welcome.
 
No luck, I still get same error.

I just don't get it, how can the adp project work, but once I export to ADE I get the error?
 
ADP is a different kettle of fish.

If you open the record source of the form, i.e. open the query or table, and enter data then move to another record, does it get saved? I mean in the ADP.
 
I've added a record to the ADP Contacts table without a problem, is saves and I can move away from the record.
 

Users who are viewing this thread

Back
Top Bottom