Results 1 to 9 of 9
  1. #1
    mdavid is offline Competent Performer
    Windows 10 Access 2016
    Join Date
    Oct 2017
    Posts
    160

    How to reference controls on sub forms

    Hi,


    I'm having a problem referring to controls on sub forms, below is the schema of how my forms are arranged:

    Main Form


    TabControl


    Private Sub TabCtl0_Change()
    Select Case Me.TabCtl0.Value
    Case 0
    Me.SubFormContainer.SourceObject = "SubForm1"
    Case 1
    Me.SubFormContainer.SourceObject = "SubForm2"
    End Select
    End Sub

    Note: I think part of my problem is referring to controls on SubForm2 when it's not the SubFormContainer.SourceObject - ie. SubForm1 is loaded

    SubFormContainer


    Sub Form 1

    Sub Form 1A - Continuous Form

    Button- btnCopyMemp


    Private Sub btnCopyMemp_Click()
    If IsNull(SubForm2a.txtComplaint) Then
    SubForm2A.txtComplaint = SubForm1A.txtComplaint
    End If
    End Sub

    TextBox - txtComplaint

    TextBox - txtPrep

    TextBox - txtAdmin




    Sub Form 1B - Continuous Form


    Sub Form 2


    Sub Form 2A


    TextBox - txtComplaint


    Sub Form 2B - Continuous Form

    TextBox - txtPrep

    TextBox - txtAdmin


    How do I refer to the subform controls - in red- in the code for btnCopyMemp_Click() above?

    I also need to copy txtPrep and txtAdmin from SubForm 1A to SubForm 2B - help referencing these controls also appreciated

    Sorry lost indentation in above schema, hope it's still clear.

    Thanks for any help
    David

  2. #2
    Join Date
    Apr 2010
    Location
    Steamboat Springs
    Posts
    2,529

  3. #3
    mdavid is offline Competent Performer
    Windows 10 Access 2016
    Join Date
    Oct 2017
    Posts
    160
    Hi thanks for this.
    I did try as the link suggests but get an error saying "can't find the field SubForm2".

    As I wrote (see Note before SubFormContainer) I think part of the problem is that SubForm2 is not loaded in the SubFormContainer

    Thanks
    David

  4. #4
    June7's Avatar
    June7 is offline VIP
    Windows 10 Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    52,902
    That would be a problem. Why dynamically loading objects? Is the form so complicated and slow?
    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.

  5. #5
    mdavid is offline Competent Performer
    Windows 10 Access 2016
    Join Date
    Oct 2017
    Posts
    160
    Hi June, thanks for confirming that's the problem, used this method 'cause I saw a video using it and liked the idea. I'll change it to normal tabs and let you know.
    Hopefully mark this solved.

    Thanks
    David

  6. #6
    mdavid is offline Competent Performer
    Windows 10 Access 2016
    Join Date
    Oct 2017
    Posts
    160
    Silly question - can I add an existing form (with subforms) to a page in a tab control? Googled add existing form to page but only found adding fields

    Thanks
    David

  7. #7
    Join Date
    Apr 2017
    Posts
    1,679
    Activate the page you want to add the form into (NB! the page must be activated, not the form containing the tab control);
    From object pane on left, drag the form into page;
    Adjust created subform's (there will be now a subform on page with form as source) position and dimension. Preferably rename a subform so it doesn't have same name as form it contains;
    In case you want the created subform to link to parent form, and the link was not created automatically (p.e. because parent form is unbound one), edit subform's properties to estabilish links.

  8. #8
    mdavid is offline Competent Performer
    Windows 10 Access 2016
    Join Date
    Oct 2017
    Posts
    160
    Thanks for this - I've already started copying the first page.
    I'll try your method on the page2

  9. #9
    mdavid is offline Competent Performer
    Windows 10 Access 2016
    Join Date
    Oct 2017
    Posts
    160
    Thanks all,
    All sorted and working

    David

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

Similar Threads

  1. Compare controls of two forms
    By newbieX in forum Programming
    Replies: 7
    Last Post: 10-07-2014, 09:06 AM
  2. Forms Controls, Methods and Properties
    By cfwoodbury in forum Access
    Replies: 5
    Last Post: 10-09-2012, 09:35 AM
  3. Referencing Controls on Forms
    By cbh35711 in forum Access
    Replies: 7
    Last Post: 04-05-2012, 09:04 PM
  4. Controls in forms and subforms
    By donnan33 in forum Access
    Replies: 2
    Last Post: 01-05-2012, 10:29 AM
  5. Filling controls on two forms
    By recon2011 in forum Forms
    Replies: 3
    Last Post: 09-01-2011, 01:54 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