Results 1 to 10 of 10
  1. #1
    deanaldo is offline Novice
    Windows 7 32bit Access 2010 32bit
    Join Date
    Jul 2012
    Posts
    5

    Basing combo one combo box on another

    Hi,

    I have a sub-form on a form that I use 3 combo boxes to filter down choices for a certain field. I have the first combo box that shows 'Type of Source', the next combo box is 'Advertiser Name' and the final box shows 'Campaign '. So the user picks a Type of source, and then the advertiser box only shows advertisers that are the same type of source picked, then the user picks a campaign that has been assigned to that advertiser.



    I am having problems with updating the combo boxes. On form current I have all three combo boxes re queried

    Code:
    ComboSource.RequeryComboAdvertiser.Requery
    ComboCampaign.Requery
    On form load I have the following

    Code:
    ComboSource = NullComboSource.Requery
    ComboSource = ComboSource.ItemsSelected(0)
    Call ComboAdvertiser_AfterUpdate
    On the comboSource box I have the following event after update

    Code:
    ComboAdvertiser = NullComboAdvertiser.Requery
    ComboAdvertiser = ComboAdvertiser.ItemData(0)
    
    
    ComboCampaign = Null
    ComboCampaign.Requery
    ComboCampaign = ComboCampaign.ItemData(0)
    On the comboadvertiser box, I have the following event after update

    Code:
    ComboCampagin.Requery
    ComboCampaign = ComboCampaign.ItemData(0)
    When I create a new entry and fill in all the data, the criteria works ok, but when I navigate to an old record, the combosource and comboadvertiser boxes stay the same and dont change, and when I go back to the record I created only the comboCampaign box shows the correct information, the other two are blank. Can someone help me please?

    Thanks

  2. #2
    June7's Avatar
    June7 is online now VIP
    Windows XP Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    52,929
    ComboCampaign in the last code snip is misspelled. Some of the lines are running into each other. I assume these are typos in the post.

    Are combosource and comboadvertiser unbound?

    Want to provide db for analysis? Follow instructions at bottom of my post.
    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.

  3. #3
    deanaldo is offline Novice
    Windows 7 32bit Access 2010 32bit
    Join Date
    Jul 2012
    Posts
    5
    Quote Originally Posted by June7 View Post
    ComboCampaign in the last code snip is misspelled. Some of the lines are running into each other. I assume these are typos in the post.

    Are combosource and comboadvertiser unbound?

    Want to provide db for analysis? Follow instructions at bottom of my post.
    Ye that is a typo in the post.

    ComboSource is unbound, ComboAdvertiser is unbound and ComboCampaign is bound to a field.

    Unfortunately I can't send the DB over as it is full of confidential data, and also over 100MB.

    Thanks for your reply.

  4. #4
    June7's Avatar
    June7 is online now VIP
    Windows XP Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    52,929
    Probably wouldn't need the entire db. An extract of the objects relevent to this issue and a reduced dataset (without confidential data) might be enough to test with.

    When I create a new entry and fill in all the data, the criteria works ok, but when I navigate to an old record, the combosource and comboadvertiser boxes stay the same and dont change, and when I go back to the record I created only the comboCampaign box shows the correct information, the other two are blank.
    What behavior do you want?

    Maybe in the Current event need to set the first two comboboxes to null.

    I have never mixed bound/unbound dependent comboboxes. Usually I use dependent comboboxes just to input filter criteria and those comboboxes would all be unbound. One case I did use bound dependent comboboxes, both values had to be saved. It was a weird data relationship.
    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
    deanaldo is offline Novice
    Windows 7 32bit Access 2010 32bit
    Join Date
    Jul 2012
    Posts
    5
    Quote Originally Posted by June7 View Post
    What behavior do you want?
    I want the user to have to filter down which campaigns are shown by only showing those that match criteria in the first two boxes.

    So the first box the user has is Type of Source(Newspaper, TV, Magazine, Internet etc.), then the next box will be Advertiser Company (Google, BBC, GQ, Financial Times etc.), but only the relevant advertisers will show for the type of source selected(for example, BBC will only show when TV has been selected as type of source, Google will only shown when internet has been selected as type of source etc.)

    Finally the last box will only show campaigns that have been used with that Advertiser(usually referenced by date), so for example the advertiser selected is GQ. There may have been two adverts placed in GQ over a year, there would be two entries in this box showing the date(which is the unique identifier).

    Now when a user naviagates to the next customer record, all the boxes should either reset if no information is present, or if the customer has previously had all this information entered, it should show it.

    Do you understand a bit more about what I'm trying to achieve?

  6. #6
    June7's Avatar
    June7 is online now VIP
    Windows XP Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    52,929
    Can use the form Current event to 'reset' the comboboxes. This event will execute when the form first opens and when navigating records. I would set the second and third comboboxes as disabled and value null. Then code in the first combobox AfterUpdate would enable and requery the second. Code in the second AfterUpdate would enable and requery the third.
    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.

  7. #7
    deanaldo is offline Novice
    Windows 7 32bit Access 2010 32bit
    Join Date
    Jul 2012
    Posts
    5
    I understand what your trying to say and can see that this would work for any new records created, but what about when you go back over old records to view information? Would it not just reset all comboboxes thus lose the data saved?

  8. #8
    June7's Avatar
    June7 is online now VIP
    Windows XP Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    52,929
    Comboboxes used to enter criteria to filter records should be unbound and thus will not affect the data in table.

    If you are using the comboboxes to aid in data entry (they are bound to a field), 'resetting' the RowSource of each combobox will not affect the data saved, just don't set the combobox Value by code.
    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.

  9. #9
    deanaldo is offline Novice
    Windows 7 32bit Access 2010 32bit
    Join Date
    Jul 2012
    Posts
    5
    Quote Originally Posted by June7 View Post
    Comboboxes used to enter criteria to filter records should be unbound and thus will not affect the data in table.

    If you are using the comboboxes to aid in data entry (they are bound to a field), 'resetting' the RowSource of each combobox will not affect the data saved, just don't set the combobox Value by code.
    The comboboxes are unbound at the moment. When I go back to a previous record, the comboboxes show the entrys from whatever values I last entered into them, I would like them to show the values for whatever the data value is, is that possible?

  10. #10
    June7's Avatar
    June7 is online now VIP
    Windows XP Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    52,929
    If purpose of comboboxes is just to filter records, they should not be bound and I recommend code simply null the boxes after the filter action and use other boxes to display the field values.

    If you want the combos to show the data in table the boxes must be either bound or use code to populate the box with value from the current record.

    Me.comboboxname = Me!fieldname
    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.

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

Similar Threads

  1. Replies: 5
    Last Post: 03-12-2012, 02:58 AM
  2. Replies: 33
    Last Post: 01-13-2012, 07:44 AM
  3. Replies: 4
    Last Post: 08-16-2011, 05:54 PM
  4. Replies: 5
    Last Post: 01-02-2011, 10:09 AM
  5. Basing one combo box on another in a subform
    By LFosterAccess in forum Forms
    Replies: 8
    Last Post: 10-07-2009, 01:19 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