Hi,

I need some help with muliselect list boxes.

Can someone please take a look at the attached database and tell me why my form isnt able to return the required data?

Here is how it is suppoed to work:
- open the form
- enter required information
- the herd size and the age of farmer are linked to the query using a criteria
- the county is linked to the query using the following code:

Option Compare Database
Option Explicit

Private Sub OK_Click()
On Error GoTo Err_OK_Click

Dim strWhere As String
Dim ctl As Control
Dim varItem As Variant
'make sure a selection has been made
If Me.Enter_county_of_farm_operations.ItemsSelected.C ount = 0 Then
MsgBox "Must select at least 1 county"
Exit Sub
End If
'add selected values to string
Set ctl = Me.Enter_county_of_farm_operations
For Each varItem In ctl.ItemsSelected
'strWhere = strWhere & ctl.ItemData(varItem) & ","
'Use this line if your value is text
strWhere = strWhere & "'" & ctl.ItemData(varItem) & "',"
Next varItem
'trim trailing comma
strWhere = Left(strWhere, Len(strWhere) - 1)
'open the report, restricted to the selected items
DoCmd.OpenReport "Report", acPreview, , "ClientID IN(" & strWhere & ")"
Exit_OK_Click:
Exit Sub
Err_OK_Click:
MsgBox Err.Description


Resume Exit_OK_Click
End Sub


When I click OK, I get an error.

Can someone tell what is wrong with my form code.

THANK YOU VERY MUCH in advance!