Results 1 to 6 of 6
  1. #1
    Join Date
    Apr 2004
    Posts
    173

    Unanswered: Accessing Combo Box Column Value From A Subform

    OK, I thought I had a reference to this on my box someplace, but it appears it has been misplaced. I need to set the row source property on a subform combo box based on the value of the selected column in the main form.

    Can anybody refer me to a guide to the forms!FormName].form.controlname.property -- syntax. Any help appreciated thanks.

  2. #2
    Join Date
    Nov 2003
    Posts
    1,487
    As shown in the MS-Access Help under the heading Form Object:

    Forms!OrderForm.ctlSubForm.Form!Controls.NewData

    OR

    Forms!OrderForm.ctlSubForm!NewData


    I personaly always use:

    Forms("MainFormName")("SubFormControlName").Form.ControlNameInSubForm

    I don't know why...just habbit I guess. It's suppose to be slower but I don't really notice the difference.

    .
    Environment:
    Self Taught In ALL Environments.....And It Shows!


  3. #3
    Join Date
    Dec 2002
    Location
    Préverenges, Switzerland
    Posts
    3,740
    ?? where is the code running ?

    code in the main form passing a value to subform:
    Me!SubFormControlName!NameOfControlInSubform

    code in the subform picking up a value from main:
    Me.Parent.Form.NameOfControlInMainForm

    asking access to scan through the Forms! collection is slow.

    izy
    currently using SS 2008R2

  4. #4
    Join Date
    Apr 2004
    Posts
    173
    Actually this really isn't code. There is a combo box in the subform that uses a value in column(5) of a combo box on the parent form. It uses that value in the SQL that makes up the row source.

    Always open for suggestion is there a better way to do what I need to do.

  5. #5
    Join Date
    Dec 2002
    Location
    Préverenges, Switzerland
    Posts
    3,740
    i live in such a strange distorted world that i probably should keep quiet.
    - but i wont.

    i would use
    mainformcombo_afterupdate
    Me!SubFormControlName!NameOfComboInSubform.rowsour ce = "SELECT this, that FROM here WHERE someField = " & me.mainformcombo.column(5)
    if numeric, or
    ...someField = '" & me.mainformcombo.column(5) & "'"
    if text

    izy

    GRRRRRRR: who is the idiot that decided to force a <space> after 50-chars-without-<space>
    currently using SS 2008R2

  6. #6
    Join Date
    Apr 2004
    Posts
    173
    I like it - I sometimes struggle with the best way to do stuff like that. Thanks for the tip.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •