Hi all
I recently sent in a post asking about retrieving data from a listbox on a
search form and opening the main form showing only the records selected from
the listbox. Ken Sheridan was kind enough to send me this bit of code:
Dim varItem As Variant
Dim strEmployeeIDList As String
Dim strCriteria As String
Dim ctrl As Control
Set ctrl = Me.lstEmployees
If ctrl.ItemsSelected.Count > 0 Then
For Each varItem In ctrl.ItemsSelected
strEmployeeIDList = strEmployeeIDList & "," &
ctrl.ItemData(varItem)
Next varItem
' remove leading comma
strEmployeeIDList = Mid(strEmployeeIDList, 2)
strCriteria = "[EmployeeID] In(" & strEmployeeIDList & ")"
DoCmd.OpenForm "frmMain", WhereCondition:=strCriteria
Else
MsgBox "No Employees Selected", vbInformation, "Warning"
End If
Now, for the most part this code works great, but on the line:
DoCmd.OpenForm "frmMain", WhereCondition:=strCriteria
I have to admit I haven't got a clue what the WhereConditon should be.
Am I being a bit of a dipstick here and it's something really simple.
Can anyone give me an idea what I have to put please.
cheers
Jim
Bob Quintal - 15 Jun 2007 11:00 GMT
> Hi all
> I recently sent in a post asking about retrieving data from a
[quoted text clipped - 19 lines]
> strCriteria = "[EmployeeID] In(" & strEmployeeIDList &
> ")"
DoCmd.OpenForm "frmMain",
> WhereCondition:=strCriteria
> Else
[quoted text clipped - 9 lines]
> have to put please. cheers
> Jim
the line
strCriteria = "[EmployeeID] In(" & strEmployeeIDList & ")"
already puts what's required.
stremployeeIDlist should just look like 12345,34567,44444 (for 3
employee ids selected).

Signature
Bob Quintal
PA is y I've altered my email address.
--
Posted via a free Usenet account from http://www.teranews.com