Hello. I am not sure exactly how to word this problem. Hopefully someone understands what I am trying to do here. I have a simple form with a text box, I enter a series of part numbers separated by newlines, and then I use the following code to query for each of the separate part numbers:
This all works perfectly, but what I need to do is have the query return the records in the same order I entered the part numbers. They are automatically returned in alphabetical order by item_no, and when I enter 15+ part numbers it becomes slightly difficult to search through them all on the form to find the one I am looking for. It would be a lot easier if they were output in the same order that I type them in. Is there any way to make this happen?
I can't seem to find any information about this, partly I think because I am not sure how to describe my problem succinctly. Thanks for any help..
Code:
Dim strSql As String
Dim part_nums() As String
Dim num As Variant
Dim multivar As Boolean
multivar = False
part_nums = Split(Me.part_no, vbCrLf)
strSql = "SELECT inv.item_no, inv.description, inv.location FROM inv WHERE "
For Each num In part_nums
If multivar Then
strSql = strSql & "OR "
End If
strSql = strSql & "inv.item_no = '" & Trim(num) & "' "
multivar = True
Next num
strSql = strSql & ");"
Application.CurrentDb.QueryDefs("qry_search_parts").SQL = strSql
This all works perfectly, but what I need to do is have the query return the records in the same order I entered the part numbers. They are automatically returned in alphabetical order by item_no, and when I enter 15+ part numbers it becomes slightly difficult to search through them all on the form to find the one I am looking for. It would be a lot easier if they were output in the same order that I type them in. Is there any way to make this happen?
I can't seem to find any information about this, partly I think because I am not sure how to describe my problem succinctly. Thanks for any help..