can't edit record anymore in a form

From: guilin (guilinmifen_at_hotmail.com)
Date: 01/21/05


Date: 21 Jan 2005 06:54:26 -0800

the Allow Edit and Allow Additions properties of the form are all set
to be true but it won't allow me to change records. I used some code to
promp before edit:

**********code starts*********************

Private Sub Form_BeforeInsert(Cancel As Integer)
'ask user if they want to add a record
Dim strMsg As String

strMsg = "Do you want to add a new invoice?"
strMsg = strMsg & "Click Yes to add or No to cancel."

If MsgBox(strMsg, vbQuestion + vbYesNo, "Add Record?") = vbYes Then
AllowAdditions = True
Else
Cancel = True
End If

End Sub

Private Sub Form_BeforeUpdate(Cancel As Integer)
'ask user if they want to save the updated record
Dim strMsg As String
Dim intResponse As Integer

strMsg = "You are about to change this invoice detail. "
strMsg = strMsg & "Do you wish to save the changes?"
strMsg = strMsg & "Click Yes to Save or No to Discard changes."

intResponse = MsgBox(strMsg, vbYesNoCancel, "Update Data?")

Select Case intResponse
Case vbYes
Case vbNo
DoCmd.RunCommand acCmdUndo
Cancel = True
Case vbCancel
Cancel = True
End Select

End Sub

**********************code ends**********************************
this form also has a parent form so it can be opened from its parent or
on its own, don't know whether it changes things?
thanks for all advice....................



Relevant Pages

  • Re: Event Fires Twice
    ... Cancel the event, ... Private Sub Form_BeforeUpate ... Dim strMsg As String ...
    (microsoft.public.access.formscoding)
  • Re: Event Fires Twice
    ... Cancel the event, and the data doesn't get saved. ... Private Sub Form_BeforeUpate ... Dim strMsg As String ...
    (microsoft.public.access.formscoding)
  • RE: Confirm data change on close
    ... the Close event has no Cancel parameter. ... Dave Hargis, Microsoft Access MVP ... Private Sub Form_BeforeUpdate ... Dim strMsg As String ...
    (microsoft.public.access.formscoding)
  • Re: On close check for blank entries
    ... If all you want is a warning message then eliminate the lines that read ... Cancel = True and test the length of the strMsg ... Private Sub Form_Unload ... Dim strMsg As String ...
    (microsoft.public.access.gettingstarted)
  • Re: Can Outlook warn if sending with a blank subject line
    ... Private Sub Application_ItemSend _ ... (ByVal Item As Object, Cancel As Boolean) ... Dim strMsg As String ... Author of Configuring Microsoft Outlook 2003 ...
    (microsoft.public.outlook)