Results 1 to 3 of 3
  1. #1
    Bcanfield83 is offline Advanced Beginner
    Windows 7 32bit Access 2016
    Join Date
    May 2018
    Posts
    81

    Question Pass value from Main Form (List Box) to SubForm (Text Box)

    I have a Main Form called frmProject_Management
    On this form is a List Box in which users select a Project.
    The form then contains a Subform Container called "subformTasks". The actual form displayed in that container is called "subfrmProject_Tasks".


    • Main Form = frmProject_Management
    • List Box (on Main Form) = listProjects
    • Subform Container (on Main Form) = subformTasks
    • Actual Form Name That Appears in subformTasks = subfrmProject_Tasks
    • Text Box (in Subform) = txtProjIDSub


    I'm looking to have that Text Box located in the Subform (txtProjectID) simply display the bound value that's in the List Box (which represents the Project ID #).


    I've tried multiple things but the Text Box on the Subform remains blank. I also have a Text Box on the main form that displays the Project ID # value from the List Box. That works perfectly fine. I just can't seem to pass that value to the Text Box on my subform.

    I've looked here and tried various syntax:
    https://bytes.com/topic/access/insig...items-sub-form

    This is how I currently have it coded; like I said, the Text Box on the Main Form (txtProjIDMain) works fine. When I pick a Project from the List Box, the associated Project # appears in that Text Box. However, the Text Box on the Subform is blank.

    Code:
    Private Sub lstOpen_Click()
    
    
    Set ctlrole = Me.txtProjIDMain 'Hidden Text Box on the Main Form
    Set ctlrole2 = Me.[subformCompletedTasks].Form.[txtProjIDSub]
    
    
    'Display the Project ID # for the Project Selected in the List Box in the txtProjName1 (hidden) control
    ctlrole = Me.lstOpen.Column(0)
    ctlrole2 = Me.lstOpen.Column(0)
    
    
    Me.Requery
    
    
    End Sub

  2. #2
    davegri's Avatar
    davegri is offline Excess Access
    Windows 10 Access 2016
    Join Date
    May 2012
    Location
    Denver
    Posts
    3,413
    Code:
    Private sub lstOpen_click()
        me.txtProjIDMain = me.lstOpen.column(0)
        me!subformCompletedTasks.Form!txtProjIDSub = me.lstOpen.Column(0)
    end sub
    subformCompletedTasks is the name of the control on the main form holding the subform.

    If the lstOpen rowsource is "Select field1, field2, field3 from tblFields;
    then the txtboxes will show field1.
    Last edited by davegri; 08-28-2018 at 12:29 PM. Reason: added info

  3. #3
    Bcanfield83 is offline Advanced Beginner
    Windows 7 32bit Access 2016
    Join Date
    May 2018
    Posts
    81
    Thanks! I'm all set now.

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

Similar Threads

  1. Filter subform from text box on main form
    By ittechguy in forum Macros
    Replies: 5
    Last Post: 09-21-2015, 10:55 PM
  2. Replies: 3
    Last Post: 04-03-2015, 04:36 PM
  3. Replies: 19
    Last Post: 06-30-2014, 04:36 PM
  4. Replies: 1
    Last Post: 04-14-2014, 01:38 PM
  5. Replies: 4
    Last Post: 02-04-2012, 12:51 PM

Tags for this Thread

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