Results 1 to 5 of 5
  1. #1
    2 Star Lounger
    Join Date
    May 2002
    Posts
    113
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Macros on a Form in Access (Access 2002)

    I have a macro on the switchboard that opens a Form in "Read Only" Data Mode. I try to put a similar macro on the same form that, when clicked will put this form in "Edit" Data Mode. The Read Only macro works but when the Edit macro is clicked I'm still unable to edit/change the form data. Any ideas? Thanks in advance.

  2. #2
    Plutonium Lounger
    Join Date
    Dec 2000
    Location
    Sacramento, California, USA
    Posts
    16,775
    Thanks
    0
    Thanked 1 Time in 1 Post

    Re: Macros on a Form in Access (Access 2002)

    You'll have to tell us what the "edit" macro does. If the form is already open, you need to change the AllowEdits property to true, but you aren't opening the form from that macro, so what does it do?
    Charlotte

  3. #3
    2 Star Lounger
    Join Date
    May 2002
    Posts
    113
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Macros on a Form in Access (Access 2002)

    Thanks Charlotte for the info; I apologize for being too vague. Here's the situation; when the data input person opens the form we don't want accidental data deletion or changes; opening in Read Only prevents this. However, when the form is open and the data person is ready to input data, the form should be available in the Edit mode. We thought an "Edit" macro positioned on the form that allowed this form to be opened in the edit mode would work allowing data entry; but it doesn't work. Any ideas what we could do to prevent unwanted form changes and, when ready, change the form to be able to make changes. Thanks in advance for any info.

  4. #4
    Plutonium Lounger
    Join Date
    Mar 2002
    Posts
    84,353
    Thanks
    0
    Thanked 29 Times in 29 Posts

    Re: Macros on a Form in Access (Access 2002)

    You could put a command button on the form (for example in the form header or footer section), named cmdEdit and with caption "Edit Data". Create the following On Click event procedure for the command button:

    Private Sub cmdEdit_Click()
    On Error GoTo Err_Handler
    If Me.AllowEdits Then
    If Me.Dirty Then RunCommand acCmdSaveRecord
    Me.cmdEdit.Caption = "Edit Data"
    Me.AllowEdits = False
    Else
    Me.cmdEdit.Caption = "View Only"
    Me.AllowEdits = True
    Me.txtSomething.SetFocus
    End If
    Exit Sub
    Err_Handler:
    MsgBox Err.Description, vbExclamation
    End Sub

    Here, txtSomething is the first control in which the user can enter data.

    The On Click procedure toggles the Allow Edits property of the form, and also changes the caption of the command button to an appropriate text. Finally, if the form has been placed in edit mode, the appropriate control is made active.

  5. #5
    2 Star Lounger
    Join Date
    May 2002
    Posts
    113
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Macros on a Form in Access (Access 2002)

    Thanks Hans; I'll give that a try. Appreciate your time.
    BDub

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •