Results 1 to 10 of 10
  1. #1
    afshin is offline Advanced Beginner
    Windows XP Access 2007
    Join Date
    Apr 2011
    Posts
    63

    Allow edit or not in form & sub form

    i have a one form with some sub form.
    when user don't want to insert any record,i want to form not editable.
    but when user want to insert some record,i want to form and sub-forms is editable.
    for this,i write:

    Private Sub Form_AfterUpdate()


    Me.AllowEdits = True
    Me.Read.Requery
    Me.Read.Visible = True
    Me.Read.Enabled = True
    Me.Read.Locked = False
    End Sub




    Private Sub Form_Load()
    Me.AllowEdits = False
    Me.Read.Enabled = False
    Me.Read.Locked = True


    End Sub

    "Read" is name of sub form.
    but when i want to insert some record in form,
    sub form don't visible.Click image for larger version. 

Name:	form.png 
Views:	14 
Size:	66.3 KB 
ID:	21102

  2. #2
    ItsMe's Avatar
    ItsMe is offline Sometimes Helpful
    Windows 7 64bit Access 2010 32bit
    Join Date
    Aug 2013
    Posts
    7,862
    Your subform resides in a control. You can hide or show the control. The form, itself, is the object that has the Allow Edits property. Your code will need to make a distinction between the two.

    Me.Read.Visible = True
    Me.Read.Form.AllowEdits = True 'Use .Form to access the form object and its properties/methods

  3. #3
    June7's Avatar
    June7 is offline VIP
    Windows 7 64bit Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    52,902
    Advise giving the subform/subreport container control a name different from the object it holds, like ctrDetails.
    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.

  4. #4
    afshin is offline Advanced Beginner
    Windows XP Access 2007
    Join Date
    Apr 2011
    Posts
    63
    i test not only suggestion of ItsMe but also June7,but my sub form is invisible yet.

  5. #5
    ItsMe's Avatar
    ItsMe is offline Sometimes Helpful
    Windows 7 64bit Access 2010 32bit
    Join Date
    Aug 2013
    Posts
    7,862
    In order to get the correct syntax you will need to identify the name of the control that contains the subform. Do you know the name of the subform control? What did you place inside the control, is it a form object or a table object?

  6. #6
    afshin is offline Advanced Beginner
    Windows XP Access 2007
    Join Date
    Apr 2011
    Posts
    63
    Sub form name is "Read".sub form is showed in right picture,it is contain text box,combo box and other sub form.

  7. #7
    ItsMe's Avatar
    ItsMe is offline Sometimes Helpful
    Windows 7 64bit Access 2010 32bit
    Join Date
    Aug 2013
    Posts
    7,862
    Did you use the wizard to create your subform? Did you use a table object when the wizard asked you what you wanted to use as your subform?

  8. #8
    afshin is offline Advanced Beginner
    Windows XP Access 2007
    Join Date
    Apr 2011
    Posts
    63
    My sub form is other form object,not table.Click image for larger version. 

Name:	19.png 
Views:	11 
Size:	42.1 KB 
ID:	21110
    Attached Thumbnails Attached Thumbnails 19.png  

  9. #9
    ItsMe's Avatar
    ItsMe is offline Sometimes Helpful
    Windows 7 64bit Access 2010 32bit
    Join Date
    Aug 2013
    Posts
    7,862
    If the name of the Control is "Read" then you would use the example in post #2. The only other thing I can think of is to include the name within brackets.
    Me.[Read].Visible = True

    Here is some reference material on referring to subforms within forms
    http://access.mvps.org/access/forms/frm0031.htm

  10. #10
    afshin is offline Advanced Beginner
    Windows XP Access 2007
    Join Date
    Apr 2011
    Posts
    63
    i test all of them:
    Me.[Read].Visible = True
    Me!Read.Form.Visible = True
    but sub form1 and sub form2 invisible yet.
    but when i open that sub forms in design view,visible property of them are YES.

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

Similar Threads

  1. Replies: 21
    Last Post: 08-05-2013, 06:23 AM
  2. Cannot Edit Form
    By Derrick T. Davidson in forum Queries
    Replies: 7
    Last Post: 06-16-2013, 07:26 AM
  3. Replies: 1
    Last Post: 05-31-2013, 08:53 AM
  4. Search table in form / edit data in form
    By Guitarzan in forum Access
    Replies: 3
    Last Post: 10-02-2012, 11:37 AM
  5. Replies: 1
    Last Post: 12-04-2011, 09:11 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