MS Access 2007 - Cycling through values in a list box to grab id's for a SQL statement

前端 未结 1 1353
梦谈多话
梦谈多话 2020-12-06 22:47

Lets say I have two tables, one for transactions, and another table who\'s primary key is the foreign key in the first table, and this relationship simply associates locatio

相关标签:
1条回答
  • 2020-12-06 23:22

    You can use

    WHERE LocationID IN (" & listofvalues & ");"
    

    The list can be obtained like so:

    For Each itm In Me.ListBox.ItemsSelected
      listofvalues = listofvalues & "," & Me.ListBox.Column(0, itm)
    Next
    
    listofvalues = Mid(listofvalues,2)
    

    This is for a numeric list, a list of strings needs quotes.

    0 讨论(0)
提交回复
热议问题