Error 2046 Save Record isn't Avail now

L

Leslie

I have a 'Save' button on the footer of a Form. I had some code which worked
just fine using the Save Record function:

If IsNull(GroupName) Then
MsgBox "Group Name is required. Please Correct."
Else
DoCmd.RunCommand acCmdSaveRecord
DoCmd.GoToRecord , , acNewRec
End If

I modified the above to do some more error checking, and now I get 'Error
2046 - Save Record isn't available now". I searched the discussion group and
help and didn't find my answer. Here's the code I have now. Anyone have
any ideas why I'm getting this error?

If IsNull(SoftwareName) Then
MsgBox "Software Name is required. Please Correct."
DoCmd.GoToControl "SoftwareName"
Exit Sub
End If

If Me!SoftwareName.Value = Me!SoftwareName.OldValue Then
DOCMD.RUNCOMMAND ACCMDSAVERECORD
Else
If Not IsNull(DLookup("[SoftwareName]", "Software", "[SoftwareName] = " _
& Chr(34) & Me!SoftwareName & Chr(34))) Then
iAns = MsgBox("This SOFTWARE already exists! Click OK and please try
over.", vbOKCancel)
If iAns = vbOK Then
Cancel = True
Me.Undo
Else
Me.SoftwareName.Value = Null
End If
End If
Exit Sub
End If

Exit_ButtonSave_Click:
' DoCmd.RunCommand acCmdSaveRecord
DoCmd.GoToRecord , , acLast
DoCmd.GoToRecord , , acNext
Exit Sub

Err_ButtonSave_Click:
MsgBox "Error in ButtonSave_AfterUpdate() in" & vbCrLf & Me.SoftwareName
& _
" form." & vbCrLf & vbCrLf & _
"Error #" & Err.Number & vbCrLf & Err.Description
Err.Clear
Me.SoftwareName.Undo

End Sub
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top