Page 2 of 2 FirstFirst 12
Results 16 to 17 of 17
  1. #16
    davegri's Avatar
    davegri is offline Excess Access
    Windows 10 Access 2016
    Join Date
    May 2012
    Location
    Denver
    Posts
    3,388
    This setup will configure your form to only allow adding new records unless the 'cobEdit' button is clicked.
    Then the form will act as a normal fully functional form.

    Set form properties:
    DataEntry = True
    AllowAdditions = True
    AllowDeletions=True
    AllowEdits=True

    Then change original code:

    Code:
    Private Sub cobEdit_Click()
         If MsgBox("If you change the name it will change all History.  Better to create a new account", vbYesNo, "1st Edit Confirmation") = vbYes Then
            If MsgBox("Are you SURE you want to EDIT?" & vbCrLf & _
                "I STRONGLY suggest a new account.", vbYesNo, "2nd EDIT Confirmation") = vbYes Then
        DateEntry = False
          End If
            End If  
    End Sub
    You may want another button to turn off edits after allowing them by setting DataEntry = True




  2. #17
    davegri's Avatar
    davegri is offline Excess Access
    Windows 10 Access 2016
    Join Date
    May 2012
    Location
    Denver
    Posts
    3,388
    Here's an even better solution, with inputs for all possibilities. You can't use a combobox on the form for this because the combo will disable itself as soon as ENABLE EDITS is false.

    Code:
    Private Sub cobEdit_Click()
        Dim x As String
        x = InputBox("Select data mode: Enter 1,2, or 3" & vbCrLf _
        & "1 New Records Only" & vbCrLf _
        & "2 View Existing Records" & vbCrLf _
        & "3 Edit Existing Records", "C H O O S E  A  D A T A  M O D E", 0)
        Select Case x
            Case 1  'New records only
                Me.DataEntry = True
            Case 2  'View records only
                Me.DataEntry = False
                Me.AllowEdits = False
            Case 3  'edit existing records
                If MsgBox("If you change the name it will change all History.  Better to create a new account." & vbCrLf _
                & "Do you want to continue to edit?", vbYesNo, "1st Edit Confirmation") = vbYes Then
                    If MsgBox("Are you SURE you want to EDIT?" & vbCrLf & _
                        "I STRONGLY suggest a new account.", vbYesNo, "2nd EDIT Confirmation") = vbYes Then
                            Me.DataEntry = False
                            Me.AllowEdits = True
                    End If
                End If
            Case Else
                MsgBox "No change chosen"
        End Select
    End Sub
    Last edited by davegri; 12-10-2021 at 11:05 AM. Reason: Included OP's warning messageboxes

Page 2 of 2 FirstFirst 12
Please reply to this thread with any new information or opinions.

Similar Threads

  1. Command Button On Subform not working
    By aamer in forum Access
    Replies: 2
    Last Post: 12-21-2019, 05:57 PM
  2. Replies: 3
    Last Post: 03-15-2019, 06:05 PM
  3. Replies: 13
    Last Post: 01-22-2015, 05:27 PM
  4. command button for allow edits
    By phineas629 in forum Forms
    Replies: 1
    Last Post: 10-18-2011, 07:09 PM
  5. Replies: 1
    Last Post: 07-27-2010, 02:27 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Other Forums: Microsoft Office Forums