Results 1 to 11 of 11
  1. #1
    djclinton15 is offline Competent Performer
    Windows 8 Access 2013
    Join Date
    Nov 2015
    Posts
    123

    Datasheet Forms & Subforms?

    I have many Datasheet Forms that has Datasheet Forms within them. The issue I’m having is the I wish for certain Datasheet Forms to open up with the sub-forms collapse, while I would want other Datasheet Forms to open up with the sub-forms expanded. Now, I’m sure many will suggest for me to close out sub-form I want expanded leave the sub-form expanded when closed. And, close out sub-form I want collapse leave the sub-form collapse when closed. Are there reasons why some sub-forms opens up collapse & other sub-forms will open expanded?

    Any advice/suggestion would be greatly appreciated! Thanks in advance!

  2. #2
    John_G is offline VIP
    Windows 7 32bit Access 2010 32bit
    Join Date
    Oct 2011
    Location
    Ottawa, ON (area)
    Posts
    2,615
    I don't know what you mean by "collapse" - Access doesn't have such a feature - but what you can do is make the main form control containing the subform visible or not visible as required. Would that work for you?

  3. #3
    jwhite is offline Competent Performer
    Windows 10 Access 2013 32bit
    Join Date
    Dec 2012
    Location
    North Carolina
    Posts
    349
    Is it possible you are opening a table directly, and at top left of that table clicking the "+" button to open the related records to that table? If that is the case, table datasheets and subdatasheets are not designed for complex data-entry. You need to design a form with subforms for your data-entry. See http://allenbrowne.com/bug-09.html for a detailed review of this "feature" and how to remove the subdatasheets.

  4. #4
    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
    This doesn't only apply to opening Tables, directly...when you have Subforms on Datasheet View Forms, the Record on the MainForm appear with a (+) (Plus Sign). To view the Subform(s) for a given Record you click on the (+). In order for all of the Subforms to be dropped down when your MainForm opens, in the MainForm use this code
    Code:
    Private Sub Form_Load()
      Me.SubdatasheetExpanded = True
    End Sub

    To have them appear 'collapsed,' set it as

    Me.SubdatasheetExpanded = False

    Linq ;0)>
    The problem with making anything foolproof...is that fools are so darn ingenious!

    All posts/responses based on Access 2003/2007

  5. #5
    djclinton15 is offline Competent Performer
    Windows 8 Access 2013
    Join Date
    Nov 2015
    Posts
    123
    Thanks to everyone for responding to my thread!

    Ling, much thanks! You understood & provided with exactly what I was looking for.

  6. #6
    CJ_London is offline VIP
    Windows 10 Access 2010 32bit
    Join Date
    Mar 2015
    Posts
    11,412
    As a side comment, the + only appears on the parent when a one to many relationship (i.e. enforce referential integrity) has been defined. And if a parent has more than one child table, only one table can be shown, this can be changed by manually editing the Subdatasheet Name property of a query or with code in a datasheet form

  7. #7
    djclinton15 is offline Competent Performer
    Windows 8 Access 2013
    Join Date
    Nov 2015
    Posts
    123
    Private Sub Form_Load()
    Me.SubdatasheetExpanded = True
    End Sub
    Me.SubdatasheetExpanded = False

    The above code resolved my issue, however now it prohibits me to have the For open in a particular field. This code no longer works. I get this error message saying, ‘The expression you entered in the property setting produced the following error message: :Ambiguous name detected: Form_Load”
    Private Sub Form_Load()
    DoCmd.GoToRecord , , acNewRec
    Me.ArtistsIDcbx.SetFocus
    End Sub

  8. #8
    davegri's Avatar
    davegri is online now Excess Access
    Windows 10 Access 2016
    Join Date
    May 2012
    Location
    Denver
    Posts
    3,407
    I think that's trying to tell you that you have more than one sub named Form_Load in the same scope (form).

  9. #9
    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
    That's exactly the problem...you can only have one sub named Form_Load! You have to put all of your code inside a single Form_Load:

    Code:
    Private Sub Form_Load()
      Me.SubdatasheetExpanded = True
      DoCmd.GoToRecord , , acNewRec
      Me.ArtistsIDcbx.SetFocus
    End Sub

    Be sure to delete the second sub!

    Linq ;0)>
    Last edited by Missinglinq; 01-05-2017 at 05:22 PM.
    The problem with making anything foolproof...is that fools are so darn ingenious!

    All posts/responses based on Access 2003/2007

  10. #10
    djclinton15 is offline Competent Performer
    Windows 8 Access 2013
    Join Date
    Nov 2015
    Posts
    123
    ling, this code worked perfectly for 5-days until today. I don't understand nor can figure out what (if any) changes to disrupt the code. This has me so mad & frustrated!

    Private Sub Form_Load()
    Me.SubdatasheetExpanded = True
    DoCmd.GoToRecord , , acNewRec
    Me.ArtistsIDcbx.SetFocus
    End Sub

  11. #11
    John_G is offline VIP
    Windows 7 32bit Access 2010 32bit
    Join Date
    Oct 2011
    Location
    Ottawa, ON (area)
    Posts
    2,615
    What line does the code fail on and what is the error message? I see nothing obvious in the code.

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

Similar Threads

  1. Forms and Subforms
    By jlgray0127 in forum Forms
    Replies: 3
    Last Post: 04-11-2013, 02:24 PM
  2. Replies: 5
    Last Post: 01-16-2013, 03:48 PM
  3. Replies: 5
    Last Post: 10-27-2011, 01:00 PM
  4. forms and subforms
    By phineas629 in forum Forms
    Replies: 4
    Last Post: 10-05-2011, 02:46 PM
  5. Help with Forms and Subforms
    By xstaceyid in forum Forms
    Replies: 1
    Last Post: 04-21-2011, 02:14 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