Results 1 to 7 of 7
  1. #1
    faythe1215 is offline Advanced Beginner
    Windows 7 64bit Access 2007
    Join Date
    Jul 2014
    Posts
    52

    Unable to Edit in SubForm

    I am currently attempting to fix my "frmRecipes" with subform "frmIngredients". I have been working on the "Add" button.



    Functionally speaking, I should be able to click the "Add" button and basically populate a blank field. I am able to edit everything on the main form, but not on the subform. I checked the subform's properties and the only thing I have not allowed are deletions.

    I have attached a copy of the database for review. Thanks in advance!

    Attachment 19598

  2. #2
    June7's Avatar
    June7 is offline VIP
    Windows 7 64bit Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    53,770
    The code works. New record added in both tables. Don't know yet why can't edit subform. The subform isn't even showing records. I've never tried anything like this with subform.

    I have narrowed it down to the AllowEdits property on the main form. When this is set to No, the subform records do not show and the subform is not editable. Even though code modifies this property, it still doesn't seem to set the subform as editable.
    How to attach file: http://www.accessforums.net/showthread.php?t=70301 To provide db: copy, remove confidential data, run compact & repair, zip w/Windows Compression.

  3. #3
    Missinglinq's Avatar
    Missinglinq is offline VIP
    Windows 7 64bit Access 2007
    Join Date
    May 2012
    Location
    Richmond (Virginia, not North Yorkshire!)
    Posts
    3,018
    When a Form's AllowEdits Property is set to No, you cannot edit Controls on that Form. What we typically call a Subform is, in reality, a Subform Control, and hence it cannot be edited, when the above is true. How the AllowEdits Property is set on the Form that resides in the Subform Control doesn't really matter.

    The usual workaround is to set the Main Form's AllowEdits Property to Yes, but to Lock all of its Controls on the Main Form except the Subform Control.

    Linq ;0)>

  4. #4
    faythe1215 is offline Advanced Beginner
    Windows 7 64bit Access 2007
    Join Date
    Jul 2014
    Posts
    52
    My code actually sets AllowEdits to True, which, as far as I know, is why I'm able to edit the Recipe Name and other objects in the main form.

    Since I have it set to True and am able to edit things in the main form, shouldn't I also be able to edit the subform?

  5. #5
    Missinglinq's Avatar
    Missinglinq is offline VIP
    Windows 7 64bit Access 2007
    Join Date
    May 2012
    Location
    Richmond (Virginia, not North Yorkshire!)
    Posts
    3,018
    If I'm looking at this correctly, you're only setting AllowEdits = True after you click the button to add a New Record, which is kind of confusing, as why would you have a need to Edit a new Record?

    If you're asking why, after clicking this button that sets AllowEdits = True, you cannot then move to another Record, on the Main Form, and then Edit something on the Subform, the answer is that when

    1. AllowEdits is set to No in the Properties Pane
    2. VBA Code is used to set AllowEdits = True
    3. You move to another Record

    the AllowEdits Property, after you perform Step #3, above, reverts to its setting as done in the Property Pane, not to how it was last set in code.

    Linq ;0)>

  6. #6
    faythe1215 is offline Advanced Beginner
    Windows 7 64bit Access 2007
    Join Date
    Jul 2014
    Posts
    52
    AllowAddition was set to True so that I could add the new record.
    AllowEdits was set to True so that after the record was added I would actually be able to input the information as needed.

    I thought that setting it to true would change the form's setting - THE ENTIRE FORM - until I changed it back.

    Knowing that it works that way, I'll have to find another way to make this work... Thanks!

  7. #7
    faythe1215 is offline Advanced Beginner
    Windows 7 64bit Access 2007
    Join Date
    Jul 2014
    Posts
    52
    I'm sure this is a clumsy fix, but it worked:

    Code:
    Private Sub btnAdd_Click()
        Me.AllowAdditions = True
        DoCmd.GoToRecord , , acNewRec
        Me.RecipeName = " "
        Me.AllowAdditions = False
            
        Dim RecNum As Integer
        RecNum = Me.CurrentRecord
    
        DoCmd.OpenForm "frmIngredients"
        DoCmd.GoToRecord , , acNewRec
            ' Link to tbl1Recipe
        Forms!frmIngredients!txtRecipeID = RecNum
            ' Set to Dummy Value
        Forms!frmIngredients!cmbIngredientName = 100
        DoCmd.Close
        
        Me.Refresh
        Forms!frmRecipes.SetFocus
        Forms!frmRecipes.AllowEdits = True
    End Sub

Please reply to this thread with any new information or opinions.

Similar Threads

  1. Unable to edit report in design view
    By gdenham in forum Reports
    Replies: 1
    Last Post: 07-03-2014, 01:05 AM
  2. Replies: 13
    Last Post: 05-24-2013, 05:54 AM
  3. Unable to edit data in Union table
    By D4WNO in forum Access
    Replies: 2
    Last Post: 08-15-2012, 06:56 AM
  4. Unable to edit Data in Query
    By undee69 in forum Forms
    Replies: 4
    Last Post: 06-10-2012, 10:43 PM
  5. Replies: 12
    Last Post: 06-16-2011, 01:35 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