Results 1 to 3 of 3
  1. #1
    kowalski is offline Novice
    Windows 7 64bit Access 2010 32bit
    Join Date
    Oct 2012
    Posts
    10

    combobox rowsource per row on a subform

    I've go a subform with 2 comboboxes. It's a datasheet view.


    The combobox controls are called cmb1 and cmb2 for the sake of this...

    cmb2 is dependent on cmb1. So when you select a certain value in cmb1, cmb2.rowsource should get updated to use a certain table.

    But the kicker is that this should be on a per row basis. So if on row 1 of the subform datasheet you set cmb1=Manager, cmb2.RowSource should get set to 'tblManagers'.
    Then on the next row, cmb1 is set to Directors, cmb2.RowSource should get set to tblDirectors.
    But the cmb2.rowsource on row 1 is still set to tblManagers.

    Is this possible????

    Thanks!!!

  2. #2
    Rod is offline Expert
    Windows 7 32bit Access 2007
    Join Date
    Jun 2011
    Location
    Metro Manila, Philippines
    Posts
    679
    If the comboboxes are unbound - which I assume they are - then this is normal behaviour for datasheets, continuous forms and the like. If you set an unbound control to a value, then all records/rows in the list have that value in that control.

    What you want to do may be quite complex and it sounds suspiciously like your db is not in normal form. I can't for the moment think of a straightforward way to achieve your requirement. Thinking cap is on; I'll get back to you. Meanwhile tell us more about the comboboxes, particularly the first one.

  3. #3
    Rod is offline Expert
    Windows 7 32bit Access 2007
    Join Date
    Jun 2011
    Location
    Metro Manila, Philippines
    Posts
    679
    Cmb2 must be bound. It looks better if Cmb1 is also bound. Do not 'Limit to list' on Cmb2

    Code:
    Option Compare Database
    Option Explicit
    
    Private Sub Cmb1_BeforeUpdate(Cancel As Integer)
        Select Case Nz(Me.Cmb1, "")
        Case "A"
            Me.Cmb2.RowSource = "whatever"
        Case "B"
            Me.Cmb2.RowSource = "something else"
        End Select
        
    End Sub
    
    Private Sub Form_Current()
        Dim i As Integer
        Cmb1_BeforeUpdate i
        
    End Sub
    Not as fearsome as I thought.

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

Similar Threads

  1. Replies: 2
    Last Post: 09-21-2012, 05:42 PM
  2. Wildcard search within ComboBox to control RowSource
    By CaptainKen in forum Programming
    Replies: 22
    Last Post: 05-16-2012, 02:19 PM
  3. Replies: 1
    Last Post: 09-06-2011, 01:47 PM
  4. combobox rowsource
    By dirkvw in forum Forms
    Replies: 3
    Last Post: 06-20-2011, 05:12 PM
  5. Replies: 0
    Last Post: 08-24-2010, 06:38 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