Results 1 to 5 of 5
  1. #1
    klnlsu is offline Competent Performer
    Windows 7 64bit Access 2013
    Join Date
    Apr 2015
    Posts
    107

    Assign constants to combobox rowsource

    I have a combobox on a form that is assigned to a value list. The rowsource has "Bend";"Puncture";"Torsion";"Impact";"Tension" on the combobox property sheet. My question is how do I duplicate this in VBA. Depending on the value I put in another combobox, I want to edit the values available in this combobox. I tried the following code:

    If Forms!frmHeaderEntry!PipeTypeCombo = "Non-UL" Then
    TestTypeCombo.RowSource = "Bend"


    Else
    TestTypeCombo.RowSource = "Bend";"Puncture";"Torsion";"Impact";"Tension"
    End If

    but I get a syntax error on the line in red (the line with the single value works). I have also tried putting commas between the values. I have also tried removing the quotes. Neither works. What is the proper syntax to accomplish this? I know I can put the values in tables and assign the tables to the rowsource, but I want to keep this little database simple and straightforward.

    Thanks.

  2. #2
    ranman256's Avatar
    ranman256 is online now VIP
    Windows Vista Access 2010 32bit
    Join Date
    Apr 2014
    Location
    Kentucky
    Posts
    9,525
    try never to assign values to a combo box.
    Always use a table/query. Easy to maintain/change.
    dont do it in code.
    use the table/query as the source.

  3. #3
    pbaldy's Avatar
    pbaldy is online now Who is John Galt?
    Windows XP Access 2007
    Join Date
    Feb 2010
    Location
    Nevada, USA
    Posts
    22,521
    I would also use a table, with another field that let me determine which items to select for different options in the first combo. It would be more dynamic and maintainable. That said, the solution might be:

    TestTypeCombo.RowSource = "Bend;Puncture;Torsion;Impact;Tension"
    Paul (wino moderator)
    MS Access MVP 2007-2019
    www.BaldyWeb.com

  4. #4
    Micron is offline Virtually Inert Person
    Windows 10 Access 2016
    Join Date
    Jun 2014
    Location
    Ontario, Canada
    Posts
    12,800
    Depending on the value I put in another combobox, I want to edit the values available in this combobox.
    The answer to this part of your post would be that this is commonly known as 'cascading' combo boxes. Lots of web pages available on the topic.
    The more we hear silence, the more we begin to think about our value in this universe.
    Paraphrase of Professor Brian Cox.

  5. #5
    CJ_London is online now VIP
    Windows 10 Access 2010 32bit
    Join Date
    Mar 2015
    Posts
    11,428
    if using a list string, you also need to change to combo rowsource type from table/query to value list

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

Similar Threads

  1. Combobox filtered rowsource?
    By TerraEarth in forum Access
    Replies: 4
    Last Post: 04-03-2018, 02:28 PM
  2. Replies: 13
    Last Post: 09-07-2017, 04:11 AM
  3. Replies: 4
    Last Post: 06-29-2013, 06:44 PM
  4. combobox rowsource per row on a subform
    By kowalski in forum Access
    Replies: 2
    Last Post: 12-05-2012, 01:49 AM
  5. combobox rowsource
    By dirkvw in forum Forms
    Replies: 3
    Last Post: 06-20-2011, 05:12 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