 |
|
 |
Stadifer Level: Guest

|
List Box Scripting Problems
First off I'm going to give my code then explain my problem....
Option Compare Database
Option Explicit
Private Sub cmdCompile_Click()
Dim vntSta As Variant
Dim vntBld As Variant
Dim vntLst As Variant
Dim strState As String, strBld As String, strLst As String, strSQL As String
Dim dbs As Database
Dim qdf As QueryDef
For Each vntLst In Me!titleList.ItemsSelected
strLst = strLst + """" & _
Me![titleList].ItemData(vntLst) & """, "
Next
For Each vntSta In Me!lstState.ItemsSelected
strState = strState + """" & _
Me![lstState].ItemData(vntSta) & """, "
Next
For Each vntBld In Me!bldLst.ItemsSelected
strBld = strBld + """" & _
Me![bldLst].ItemData(vntBld) & ""","
Next
strLst = Left$(strLst, Len(strLst))
strState = Left$(strState, Len(strState) - 2)
strBld = Left$(strBld, Len(strBld) - 1)
strLst = "(" + strLst + ")"
strState = "(" + strState + ")"
strBld = "(" + strBld + ")"
If strState & strBld & strLst <> "" Then
Set dbs = CurrentDb
strSQL = "SELECT name.* INTO results FROM NAME WHERE TITLE IN " + strLst + " AND STATE IN " + strState + " AND BLDTYPE IN " + strBld + ""
Set qdf = dbs.CreateQueryDef("Compiled", strSQL)
Else
MsgBox "No data has been selected!", vbOKOnly
End If
End Sub |
The problem I have is that when someone selects something from the titleList (a list box on my form) it returns only the first item in the list. Even if you select the last title it will return only the first title in the list.
Me & Brick walls -
|
|
30-05-2003 at 07:06 PM |
|
|  |
|
|
|
|
 |
 |