ADE error which works fine in ADP

Same story, I can add a record in the Contacts table...that is in ADE.
 
Put a MsgBox Me.Dirty on that code line, make a change to the record and run the code. Tell me what the Msgbox reads.
 
It returns False.

In saying that, the previous line of code is 'If Me.Dirty Then Me.Dirty = False' as you've previously asking to me do. Should I remove this and run it again?

Got the code as follow:

Code:
Private Sub cmdSave_Click()
On Error GoTo Err_cmdSave_Click
    
    If Me.Dirty Then Me.Dirty = False
    MsgBox "This is me dirty:" & Me.Dirty
    DoCmd.RunCommand acCmdSaveRecord
    DoCmd.Close
Exit_cmdSave_Click:
    Exit Sub

Err_cmdSave_Click:
    MsgBox Err.Description
    Resume Exit_cmdSave_Click
End Sub
 
Put it before the If Dirty code line and give it a test.
 
I don't believe that this has been asked/answered; do the ADP and ADE files both reside in the same Folder when you are testing them? Since the Me.Dirty is returning True, before you try to save the Record, it sounds as if you do not have the needed Permissions, from the ADE file, to Write to the Back End file.

Linq ;0)>
 
You could try a different tack and get the DoCmd.Close to do the save for you, that way you shouldn't need DoCmd.SaveRecord at all.

Code:
Private Sub cmdSave_Click()
On Error GoTo Err_cmdSave_Click
    DoCmd.Close acForm, [B]Me.Name, acSaveYes[/B]

Exit_cmdSave_Click:
    Exit Sub

Err_cmdSave_Click:
    MsgBox Err.Description
    Resume Exit_cmdSave_Click
End Sub
 
Thanks a lot Nigel, looks like that solved my problem! Appreciate everyones help.
 
Just point out that the acSaveYes option has no effect on your records. It saves design changes to the form which is equivalent to the acCmdSave constant you had in your original post.

Obviously being an ADE, acSaveYes will have no effect on the project.
 
Seems that I've just eliminated the problem rather than solving it. :)


I've always tended to use:

Code:
Public Sub cmdExit_Click
On error resume next
DoCmd.Close acForm, Me.Name
End Sub

It seems to work for me. Any changes to the record are saved, the Form closes ... Job done.


Anyway, as long as it works correctly. ;)
 
Last edited:
:) Band aid fix, but it works.

I'm still curious as to why it doesn't work because that's a Save button and a Save action is what was required. The fix is a Close action.
 

Users who are viewing this thread

Back
Top Bottom