Results 1 to 4 of 4
  1. #1
    dcdimon's Avatar
    dcdimon is offline Advanced Beginner
    Windows XP Access 2010 32bit
    Join Date
    Sep 2013
    Location
    Bradenton, FL
    Posts
    71

    Reference a control in subform opened with VB data source change

    I am creating a Main Form (scannermainform) with a subform control in it (blankpageF). I have a number of buttons set up with onclick events that changes the Source Object of blankpageF to another form. So, when the main form is opened, it shows blankformf and when button 1 is clicked the source object for blankformf is changed to subform1. When button 2 is clicked the source object changes to subform2 and so on.



    The problem I'm having is trying to reference a control on the subforms in a query for a combo box. I'm not sure of the syntax to reference a control (equipment) from the subform that is being used as the record source. I can't use the expression builder because the subform that is attached to the main form is the blankpagef form and not subform1 or subform2. I have a feeling my problem lies in the use of ! or a '.' and whether, or where, to use the [form] option.


    The combo box is listing a product list based on the equipment data - so only the products run on a specific equipment are listed. I'm having problems writing the expression to use the data in [equipment] as a criteria.

    Main form: scannermainform
    Subform: blankpagef

    Source objects: subform1, subform2

    Control: Equipment


    Can anyone help me parse this correctly?

    Thanks, DD

  2. #2
    amrut is offline Expert
    Windows 7 64bit Access 2010 32bit
    Join Date
    Jun 2012
    Location
    Dubai
    Posts
    614

  3. #3
    Dal Jeanis is offline VIP
    Windows 7 32bit Access 2010 32bit
    Join Date
    May 2013
    Location
    Dallas TX
    Posts
    1,742
    Per that reference, which every Access programmer should bookmark...

    If the query is for a combo box on subform1, and the Equipment control is on the main form, then the syntax is
    Code:
    Me.Parent!Equipment
    If the query is on scannermainform, and the Equipment control is on subform1, then the syntax is
    Code:
    Me!blankpagef.Form!Equipment
    Remember that the Equipment control on subform1 only exists when subform1 is loaded into the blankpageF control on scannermainform.

  4. #4
    dcdimon's Avatar
    dcdimon is offline Advanced Beginner
    Windows XP Access 2010 32bit
    Join Date
    Sep 2013
    Location
    Bradenton, FL
    Posts
    71
    amrut: Thanks for the link to the form reference sheet. I had printed that out, but it had become a casualty of office moves.

    Dal: Thanks for the examples - I was having problems with the ! and '.' usage. I realize now that I had a ! where I needed a '.'. That's the hazard of using the expression builder, I wasn't really paying attention to what punctuation was going where. Not to mention the fact that I was bound and determined to use the subform being called as the name for the subform. I got stuck in that mindset and never thought about the fact that blankpagef is always my subform.

    Thanks to both of you for unscrambling my brain.

    DD

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

Similar Threads

  1. Replies: 3
    Last Post: 01-03-2013, 04:32 PM
  2. Copying entry form, change control source
    By Bdowns in forum Access
    Replies: 11
    Last Post: 02-06-2012, 05:39 PM
  3. Replies: 5
    Last Post: 10-13-2011, 03:36 PM
  4. Replies: 1
    Last Post: 05-12-2011, 02:25 PM
  5. Can't reference control in subform
    By evanscamman in forum Forms
    Replies: 0
    Last Post: 12-25-2007, 06:47 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