C
Cyndi
I found code on the net where I can have two list boxes and if I
choose an item in the first list it goes to the second, works
beautifully, I can make it print all or one stallion. What I need now
is to print two or more stallions.
It looks like the article on Web Access Use Multi Select Listbox to
limit records in reports is what I need but I can't make it work.
my 2nd list box(where the stallions are listed) is named lstchosen and
it is bound to StallionID and I have added a text box
When it gets to line Me!TxtCriteria it stops and says Runtime Error 5
Invalid procedure call or error
Can someone please help??
here is the code I have added to a command button on click event
Private Sub btnTestQuery_Click()
Dim vItm As Variant
Dim stWhat As String
Dim stCriteria As String
Dim stSQL As String
Dim loqd As QueryDef
stWhat = "": stCriteria = ","
For Each vItm In Me!lstChosen.ItemsSelected
stWhat = stWhat & Me!lstChosen.ItemsSelected(vItm)
stWhat = stWhat & stCriteria
Next vItm
Me!TxtCriteria = CStr(Left$(stWhat, Len(stWhat) -
Len(stCriteria)))
Set loqd = CurrentDb.QueryDefs("WeeklyTotals FContractsQuery")
stSQL = "SELECT StallionID, "
stSQL = stSQL & "Title FROM Stallion WHERE StallionID"
stSQL = stSQL & " IN (" & Me!TxtCriteria & ")"
loqd.SQL = stSQL
loqd.Close
DoCmd.OpenQuery "qryMultiSelTest"
End Sub
All help appreciated
choose an item in the first list it goes to the second, works
beautifully, I can make it print all or one stallion. What I need now
is to print two or more stallions.
It looks like the article on Web Access Use Multi Select Listbox to
limit records in reports is what I need but I can't make it work.
my 2nd list box(where the stallions are listed) is named lstchosen and
it is bound to StallionID and I have added a text box
When it gets to line Me!TxtCriteria it stops and says Runtime Error 5
Invalid procedure call or error
Can someone please help??
here is the code I have added to a command button on click event
Private Sub btnTestQuery_Click()
Dim vItm As Variant
Dim stWhat As String
Dim stCriteria As String
Dim stSQL As String
Dim loqd As QueryDef
stWhat = "": stCriteria = ","
For Each vItm In Me!lstChosen.ItemsSelected
stWhat = stWhat & Me!lstChosen.ItemsSelected(vItm)
stWhat = stWhat & stCriteria
Next vItm
Me!TxtCriteria = CStr(Left$(stWhat, Len(stWhat) -
Len(stCriteria)))
Set loqd = CurrentDb.QueryDefs("WeeklyTotals FContractsQuery")
stSQL = "SELECT StallionID, "
stSQL = stSQL & "Title FROM Stallion WHERE StallionID"
stSQL = stSQL & " IN (" & Me!TxtCriteria & ")"
loqd.SQL = stSQL
loqd.Close
DoCmd.OpenQuery "qryMultiSelTest"
End Sub
All help appreciated