Results 1 to 7 of 7
  1. #1
    hrghauri is offline Novice
    Windows 7 64bit Access 2010 64bit
    Join Date
    Jul 2016
    Location
    Ottawa, Ontario, Canada
    Posts
    11

    Cant change the row source of a bounded combo box in Ms-access

    I am trying to fill up the row source of a bounded combo box programmatically in Ms-Access. However, it does not show any of the numbers when I view the form.



    Code:
    Private Sub Form_Open(Cancel As Integer)
        Me.cmbErrorType.RowSourceType = "Value List"
        Me.cmbErrorType.RowSource = "1;2;3;4;5;6"
    End Sub

    When the form opens, I click on combo box, and it shows nothing in the drop down menu.
    As far as I know, row source is used to build up the items in the combo box than why is this happening ?

  2. #2
    ItsMe's Avatar
    ItsMe is offline Sometimes Helpful
    Windows 8 Access 2013
    Join Date
    Aug 2013
    Posts
    7,862
    It is probably the event that you are using. Instyead of OnOpen, try OnLoad or OnCurrent, depending on what you are trying to accomplish.

  3. #3
    hrghauri is offline Novice
    Windows 7 64bit Access 2010 64bit
    Join Date
    Jul 2016
    Location
    Ottawa, Ontario, Canada
    Posts
    11
    Nupe, that did not solve it. It turns out that it works fine when, in the table design, the look up field, is set to text box instead of combo box.

  4. #4
    ItsMe's Avatar
    ItsMe is offline Sometimes Helpful
    Windows 8 Access 2013
    Join Date
    Aug 2013
    Posts
    7,862
    OK, you did mention that the combo is bound. If you are going to use a bound combo, why not use Rowsource Type = Table and store the values in a table?

    The code you have will work in the proper event and in an unbound combo.

  5. #5
    hrghauri is offline Novice
    Windows 7 64bit Access 2010 64bit
    Join Date
    Jul 2016
    Location
    Ottawa, Ontario, Canada
    Posts
    11
    That's because there is an option button on my form. Depending on what the user chooses, the row source of the combo box should change dynamically i.e on the fly.

  6. #6
    ssanfu is offline Master of Nothing
    Windows XP Access 2010 32bit
    Join Date
    Sep 2010
    Location
    Anchorage, Alaska, USA
    Posts
    9,664
    Quote Originally Posted by hrghauri View Post
    Nupe, that did not solve it. It turns out that it works fine when, in the table design, the look up field, is set to text box instead of combo box.
    You have a look up field in the table?? You should never use look up FIELDs in a table. See http://access.mvps.org/access/lookupfields.htm

    Using your example (changing names as necessary) from Post #1, I didn't have any trouble changing from a saved Row Source Type of "Table/Query" to a "Value List" on-the-fly.

    You might try (on a copy of your dB) removing the look up field in the table and testing the combo box again.....

  7. #7
    ItsMe's Avatar
    ItsMe is offline Sometimes Helpful
    Windows 8 Access 2013
    Join Date
    Aug 2013
    Posts
    7,862
    Quote Originally Posted by ssanfu View Post

    Using your example (changing names as necessary) from Post #1, I didn't have any trouble changing from a saved Row Source Type of "Table/Query" to a "Value List" on-the-fly.
    .....
    I was reading the problem as not being able to adjust the Rowsource. I think the major hurdle is the control is bound to a lookup field in the table and you would have to use DAO to adjust the table's properties or something. Whatever the solution is, insisting on a lookup property at the table level will cause lotsa work.

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

Similar Threads

  1. Replies: 2
    Last Post: 10-03-2014, 10:07 AM
  2. Replies: 1
    Last Post: 11-28-2013, 10:03 PM
  3. Change Pivot Data Source from MS Access to SQL Server
    By rjbautista20 in forum SQL Server
    Replies: 3
    Last Post: 06-24-2013, 11:36 PM
  4. (Un)bounded forms
    By Luciano in forum Forms
    Replies: 6
    Last Post: 03-10-2013, 03:27 PM
  5. Replies: 3
    Last Post: 12-11-2012, 09:12 AM

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