Results 1 to 8 of 8
  1. #1
    New Lounger
    Join Date
    Apr 2003
    Location
    Old Saybrook, Connecticut, USA
    Posts
    21
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Toggling AllowEdits? (2003 SR1)

    Since it is relatively easy for users to make mistakes & edit things when they don't mean to, when I open the form ("cardfile"), it is set not to allow edits.
    There is a button that says "click here to allow editing" - When they click, the routine includes "AllowEdits=True" , hides the buttom and makes another button visible that says "click here to prevent editing." HOWEVER, when I include the command "AllowEdits=False" it does not take effect.
    I also notice that although the command acCmdEditingAllowed exists, there is no opposite command .
    Is it possible to create a toggle in this fashion?

    John Heckman
    heckman at heckmanco. dot com

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

    Re: Toggling AllowEdits? (2003 SR1)

    Yes, you can set allowedits to false, I've done it many times based on some predetermined condition like the number of records allowed, but you don't do it with a RunCommand argument, you do it with <code>Me.AllowEdits = False</code>. If you post the code in question, someone should be able to figure out why it isn't working as you expect.
    Charlotte

  3. #3
    Super Moderator
    Join Date
    Jun 2002
    Location
    Mt Macedon, Victoria, Australia
    Posts
    3,993
    Thanks
    1
    Thanked 45 Times in 44 Posts

    Re: Toggling AllowEdits? (2003 SR1)

    me.AllowEdits = false

    should achieve what you want. In my testing to does exactly what you say you are trying to do.

    Are you sure the code is actually executing?
    Regards
    John



  4. #4
    New Lounger
    Join Date
    Apr 2003
    Location
    Old Saybrook, Connecticut, USA
    Posts
    21
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Toggling AllowEdits? (2003 SR1)

    Charlotte,
    Thanks for the suggestion. This is driving me crazy.
    When the form opens, I set Me.AllowEdits = False. This works - i.e., I can't edit any entries. Code is
    Private Sub Form_Open(Cancel As Integer)
    Me.AllowEdits = False
    Forms!cardfile.Controls!Editmode.Visible = False
    RunCommand acCmdFilterByForm
    RunCommand acCmdClearGrid
    End Sub

    When I clidk on the button that says "click here to allow edits", again the code works (I can now edit the form)
    Code is:
    Private Sub Noedit_Click()
    Me.AllowEdits = True
    Forms!cardfile.Controls!Editmode.Visible = True
    Forms!cardfile.Controls!Editmode.SetFocus
    Forms!cardfile.Controls!Noedit.Visible = False
    End Sub

    Now I have button that says "click here to prevent edits" When I click, I know the code executes because tha button disappears and the one that says "click here to allow edits re-appears as it should. BUT, I can still edit the form!!
    Code is:

    Private Sub Editmode_Click()
    Forms!cardfile.Controls!Noedit.Visible = True
    Forms!cardfile.Controls!Noedit.SetFocus
    Forms!cardfile.Controls!Editmode.Visible = False
    Me.AllowEdits = False
    End Sub

    I have tried every combination I can thiink of (different order of commands, different focus, etc.) with no luck. Any help would be appreciated.

    John Heckman

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

    Re: Toggling AllowEdits? (2003 SR1)

    OK, I took an editable continuous form and added these two events to it:

    <pre>Private Sub cmdToggleEdits_Click()
    Me.AllowEdits = Not Me.AllowEdits
    End Sub</pre>



    <pre>Private Sub Form_Open(Cancel As Integer)
    Me.AllowEdits = False
    End Sub</pre>


    This worked. Clicking the button when AllowEdits was false made it editable. Clicking it when AllowEdits was true locked it.

    I'm suspect that your problem is related to these lines:
    <pre>RunCommand acCmdFilterByForm
    RunCommand acCmdClearGrid</pre>


    I can reproduce your problem in a form using query by form, but you don't ordinarily use that in conjunctions with the user setting the allowedits to false, and I don't see that it serves any purpose there. The user has already selected a group of records to edit. Why would they then turn them off? I don't understand what you're trying to accomplish.
    Charlotte

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

    Re: Toggling AllowEdits? (2003 SR1)

    Just as an additional note, the toggling of edits will work in a filter by form setup if you add a me.Requery after the line setting the AllowEdits= false in your button click.
    Charlotte

  7. #7
    Gold Lounger
    Join Date
    Feb 2001
    Location
    Sint Niklaas, Belgium
    Posts
    2,778
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Toggling AllowEdits? (2003 SR1)

    Before you can set the allow edits to false you have to save the record.
    Change your code to :
    Private Sub Editmode_Click()
    Forms!cardfile.Controls!Noedit.Visible = True
    Forms!cardfile.Controls!Noedit.SetFocus
    Forms!cardfile.Controls!Editmode.Visible = False
    If Me.Dirty Then
    DoCmd.RunCommand acCmdSaveRecord
    End If

    Me.AllowEdits = False
    End Sub
    Francois

  8. #8
    New Lounger
    Join Date
    Apr 2003
    Location
    Old Saybrook, Connecticut, USA
    Posts
    21
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Toggling AllowEdits? (2003 SR1)

    Francois
    Thanks a lot. That finally did the trick.

Posting Permissions

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