Results 1 to 7 of 7
  1. #1
    Lounger
    Join Date
    Apr 2008
    Location
    Jacksonville, North Carolina, USA
    Posts
    37
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Hello All

    I'm using Access 2003 and was wondering if there is a way to write a filter or query to diable the AllowEdits function in forms. I know you can turn it off in the data tab on the properties sheet, but I need it to be toggled on and off when a button is clicked on the form that opens the next form. I have a form that acts as a menu and on that menu I have to buttons edit and view but I want the people to view the same table when they click the button if they click edit they will be able to edit the form and if they click view they will only be able to view and not edit. Since its the same form if i turn the allowedits of on the form it applies to both so i need to filter it or write a query so that when I click the view it switches the allowedits to false vice true. Thank you all in advance.


    Matt

  2. #2
    Plutonium Lounger
    Join Date
    Mar 2002
    Posts
    84,353
    Thanks
    0
    Thanked 29 Times in 29 Posts
    If the button is on the form itself, you could use code like this in the On Click event of the command buttons:

    Code:
    Private Sub cmdView_Click()
      Me.AllowEdits = False
    End Sub
    
    Private Sub cmdEdit_Click()
      Me.AllowEdits = True
    End Sub
    If you want the buttons to open another form in view or edit mode, you could use code like this:

    Code:
    Private Sub cmdView_Click()
      DoCmd.OpenForm FormName:="frmData", DataMode:=acFormReadOnly
    End Sub
    
    Private Sub cmdEdit_Click()
      DoCmd.OpenForm FormName:="frmData", DataMode:=acFormEdit
    End Sub

  3. #3
    Lounger
    Join Date
    Apr 2008
    Location
    Jacksonville, North Carolina, USA
    Posts
    37
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Thanks Alot

    HansV

  4. #4
    Lounger
    Join Date
    Apr 2008
    Location
    Jacksonville, North Carolina, USA
    Posts
    37
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Hello Again

    HansV I thought that would work but I have a filter running on that form and the code needs to run after the filter is applied. Is there away to add to that filter or run after that filter is ran. I'm using a macro to run the filter.

    Thanks Again

  5. #5
    Plutonium Lounger
    Join Date
    Mar 2002
    Posts
    84,353
    Thanks
    0
    Thanked 29 Times in 29 Posts
    Which of the two bits of code from my first reply are you using? The first or the second?

  6. #6
    Lounger
    Join Date
    Apr 2008
    Location
    Jacksonville, North Carolina, USA
    Posts
    37
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Hello HansV

    I'm using the second one

  7. #7
    Plutonium Lounger
    Join Date
    Mar 2002
    Posts
    84,353
    Thanks
    0
    Thanked 29 Times in 29 Posts
    Try code like this:

    Code:
    Private Sub cmdView_Click()
      DoCmd.OpenForm FormName:="frmData"
      With Forms!frmData
    	.Filter = "..."
    	.FilterOn = True
    	.AllowEdits = False
      End With
    End Sub

Posting Permissions

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