Results 1 to 6 of 6
  1. #1
    Join Date
    Feb 2014
    Posts
    9

    Changing SubForm Source by ComboBox

    I have a form with a combobox that selects a category (cboSelectType). It is pulling its list from a table with 2 fields. Key field is form names and displays the category name in the combobox. But the actual values it holds are form names.


    There is a subform on this form where I want a form for the selected category to be loaded (sub_SelectType).

    In the BeforeUpdate for the combobox I have the following....

    Dim src As String
    src = Me.cboSelectType
    Me.Sub_SaleItems.SourceObject = src

    It works except that there are no records. In my experience. This is because the LinkChildFields and LinkMasterFields Properties are auto set to something. I need these to be blank.

    So my question is... How do I make LinkChildFields and LinkMasterFields properties Blank?

    Me.Sub_SaleItems.LinkMasterFields = "" did not work.

  2. #2
    CJ_London is offline VIP
    Windows 10 Access 2010 32bit
    Join Date
    Mar 2015
    Posts
    11,397
    you don't need the src variable, just use


    Me.Sub_SaleItems.SourceObject = Me.cboSelectType

    then follow on with

    Me.Sub_SaleItems.linkchildfields=name of family key in subform
    Me.Sub_SaleItems.linkmasterfields=name of parent key in mainform

  3. #3
    Join Date
    Feb 2014
    Posts
    9
    That's just it. The form being loaded into the subform is already being filtered by a query.

    I need the 2nd and 3rd values to be blank. I don't know how to specify them as blank. I been searching

  4. #4
    aytee111 is offline Competent At Times
    Windows 10 Access 2013 64bit
    Join Date
    Nov 2011
    Location
    Nomad
    Posts
    3,936
    In the properties of the subform object, set them to blank - if you want them to be permanently blank.

    Why are you using the BeforeUpdate event? Surely it should be the AfterUpdate?

  5. #5
    Join Date
    Feb 2014
    Posts
    9
    They are blank to begin with.

    When is design view, and sourceobject and both linkfields properties are all blank. When I manually choose a sourceobject, It auto populates the link properties with SaleItemID. When it does this, and I go to form view, only the labels are visible. No items. Then when I go back and clear the link properties and back to form view, all it well.

    Since when A selection is made with the combobox, and the form being loaded into the subform has no data, only labels, I am assuming the line (Me.Sub_SaleItems.SourceObject = src) is autopopulating the linkfields properties just like when I set the source manually. If this is indeed what is happening, I need lines to set the 2 linkfields properties to BLANK.

    Also, When you make a selection on a combobox, and dont leave it, is it updated yet to even use the AfterUpdate?

    Sorry for being a Noob. I am not a pro at this, I only have the skills to figure stuff out to get our project done.

    EDIT: I moved the code to AfterUpdate and everything is the same. The LinkChild and LinkMaster are still getting autoset when the code sets the sourceobject. I just need them both to revert to blank, empty, clear

    EDIT: I went to get a drink and a thought hit me. "Since I moved the code to AfterUpdate, let me try the nullstring thing again."

    I put (Me.Sub_SaleItems.linkchildfields = "") and (Me.Sub_SaleItems.linkmasterfields = "") under (Me.Sub_SaleItems.SourceObject = src) and it worked. Those 2 lines were giving me an error when it was in BeforeUpdate. Thank You and I will make this solved.

  6. #6
    aytee111 is offline Competent At Times
    Windows 10 Access 2013 64bit
    Join Date
    Nov 2011
    Location
    Nomad
    Posts
    3,936

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

Similar Threads

  1. Replies: 8
    Last Post: 12-01-2012, 04:17 PM
  2. Changing Query Source
    By EricF in forum Queries
    Replies: 8
    Last Post: 08-26-2011, 12:23 PM
  3. Changing Report Source
    By EricF in forum Reports
    Replies: 1
    Last Post: 07-19-2011, 12:25 PM
  4. Changing row source
    By joacro in forum Access
    Replies: 3
    Last Post: 03-06-2011, 07:35 PM
  5. changing form source while it's active! ??
    By debhead in forum Forms
    Replies: 1
    Last Post: 12-16-2010, 02:55 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