Ongoing Problems With 'DoCmd.RunCommand acCmdSaveRecord'

Darrenc

Registered User.
Local time
Today, 02:18
Joined
Apr 30, 2004
Messages
62
Hi Access Experts!

I try not to post questions on here, most of the time i can find out the answers for myself, unfortunetly i'm completely stuck with this problem.

I'm getting the following error 'The command or action 'SaveRecord' isn't available now.

I've got quite a large fairly complex database, and i use the code below quite a lot for saveing the current record.

Code:
If Me.Dirty Then
    DoCmd.RunCommand acCmdSaveRecord
End If

Most of the time it works no problem, but it doesn't work so well in the following piece of code.

Code:
Private Sub imgEmailUp_MouseDown(Button As Integer, Shift As Integer, X As Single, Y As Single)
    Me.imgEmailDown.Visible = True
    Me.imgEmailUp.Visible = False
    If Nz(Me.SupRatifiedBy.Value, "") = "" And Me.SupRatified.Value = False Then
        Select Case MsgBox("Do you want to forward this investigation on for ratification?" _
                           & vbCrLf & "" _
                           & vbCrLf & "*Note: you cannot complete the investigation" _
                           & vbCrLf & " unless it has been ratified." _
                           & vbCrLf & "" _
                           , vbYesNo Or vbQuestion Or vbDefaultButton1, "Investigation Needs Ratification")
                
            Case vbYes
                bolRatifiedchk = True
                GetCheckValues 'start the investigation module
                Me.SupResolvedBy.Value = glbUserName
                Me.SupDateResolved.Value = Date
[COLOR="green"]                If Me.Dirty Then
                    DoCmd.RunCommand acCmdSaveRecord
                End If[/COLOR]
            Case vbNo
                Exit Sub
        End Select
            Exit Sub
    End If
        Select Case MsgBox("You are about to inform goods-in that you have completed" _
                           & vbCrLf & "you part of the supplier investigation." _
                           & vbCrLf & "Do you want to continue?" _
                           , vbYesNo Or vbQuestion Or vbDefaultButton1, "Advise Goods-In To Complete?")
            
            Case vbYes
                Call SupplierInvestComplete 'send goods-in an email
                If Nz(Me.SupDateResolved.Value, "") = "" Then 'check to see if the field is empty
                    Me.SupDateResolved.Value = Date
                End If
                If Nz(Me.SupResolvedBy.Value, "") = "" Then 'check to see if the field is empty
                    Me.SupResolvedBy.Value = glbUserName
                End If
                Me.SupRatifiedBy.Value = glbUserName
                Me.SupRatifiedDate.Value = Date
[COLOR="red"]                If Me.Dirty Then
                    DoCmd.RunCommand acCmdSaveRecord
                End If[/COLOR]
                '-------------Update Supplier Record-------------
                DoCmd.SetWarnings False
                DoCmd.OpenQuery "qryudSupplierInvestigation"
                DoCmd.SetWarnings True
                '----------------------End-----------------------
            Case vbNo
                Exit Sub
        End Select
End Sub

The thing i'm really struggling with is, where i use the DoCmd.RunCommand acCmdSaveRecord thats in green, it works fine, and the record is saved. Where i use the same code thats in red, thats when i get the error.

I can't understand why it should work eairlier in the code, and not later?
can anyone give me some insight to the 'DoCmd.RunCommand acCmdSaveRecord' command?

Thanks

Darren.
 
Why is it when you struggle for a solution for ages, then soon as you ask for help you find it yourself?

Anyway, i replaced DoCmd.RunCommand acCmdSaveRecord with Me.Form.Recalc. i guess its not the 'correct' way of doing things, but it works!
 

Users who are viewing this thread

Back
Top Bottom