When my query is executed it produces no results. However, if I copy and paste the criteria from the information populated and referenced in my query, it works fine.
The criteria needs to be numbers. eg. In (1,2) The text in my criteria field is:
In ([Forms]![frm_RateLoad]![Criteria])
Here is the code:
THANK you for the help
The criteria needs to be numbers. eg. In (1,2) The text in my criteria field is:
In ([Forms]![frm_RateLoad]![Criteria])
Here is the code:
Code:
Private Sub VIEW_NewRate_Click()
On Error GoTo Err_VIEW_NewRate_Click
Dim MyDB As DAO.Database
Dim i As Integer
Dim vs As String
Dim strSQL As String
Dim strWhere As String
Dim strIN As String
Dim flgSelectAll As Boolean
Dim varItem As Variant
Dim rstTempTbl As New ADODB.Recordset
If FNU_Choice.ItemsSelected.Count = 0 Then
MsgBox "You must make a selection(s) from the list" _
, , "Selection Required !"
Else
vs = ConnectSelected(FNU_Choice, ",", 0)
'Field referenced in query
Me.Criteria = vs
DoCmd.OpenQuery "Benefit_Rate_Summary - View NEW Rate", acViewNormal
End If
'Clear listbox selection after running query
For Each varItem In Me.FNU_Choice.ItemsSelected
Me.FNU_Choice.Selected(varItem) = False
Next varItem
Exit_VIEW_NewRate_Click:
Exit Sub
Err_VIEW_NewRate_Click:
'Write out the error and exit the sub
MsgBox Err.Description
MsgBox Err.Number
Resume Exit_VIEW_NewRate_Click
End Sub
Public Function ConnectSelected(ListName As ListBox, _
Optional ByVal sDelimiter As String = ",", _
Optional ByVal iColumn As Integer = 0) As String
Dim sConnect As String
Dim vID As Variant
Dim v As Variant
If ListName.ColumnCount <= (iColumn - 1) Then
Err.Raise vbObjectError + 1501, , "The specified column doesn't exist."
End If
For Each v In ListName.ItemsSelected
vID = ListName.Column(iColumn, v)
sConnect = sConnect & CInt(vID) & sDelimiter
Next v
If Len(sConnect) Then
ConnectSelected = Left(sConnect, (Len(sConnect) - Len(sDelimiter)))
Else
ConnectSelected = ""
End If
End Function
Comment