Passing Multiple-Parameters and If Scenarios (1 Viewer)

joeserrone

The cat of the cul-de-sac
Local time
Today, 02:34
Joined
Dec 17, 2006
Messages
164
I am using a multi-select list box to pass various search parameters to a query. The code below is working great but in the IF statement at the end of my code I wanted to do the following:
Instead of the user getting a message and having them select at least one item from the list box I wanted to display all the records. The SQL query that gets the results from the hidden text box that passes the criteria is listed below my code. I'm not sure if I can do this via code or modifying my SQL Query.

......VBA Code..................................
Dim lngLoop As Long
Dim strIDs As String
strQuote = Chr$(34)

If ListCategoryEdit.ItemsSelected.Count > 0 Then
strIDs = ""
For lngLoop = 0 To ListCategoryEdit.ItemsSelected.Count - 1
strIDs = strIDs & strQuote & ListCategoryEdit.ItemData(ListCategoryEdit.ItemsSelected(lngLoop)) & strQuote & " OR "

Next lngLoop
strIDs = Left(strIDs, Len(strIDs) - 4)
txtQueryCriteria = strIDs
Forms![EditEntryForm].Requery
DoCmd.OpenForm "EditEntryForm"
'DoCmd.OpenQuery "EditQuery"
Else
txtQueryCriteria = ""
MsgBox "You must select at least one Task from the Task Selection Box!", vbExclamation
End If

.....SQL Statement..................................
SELECT Assignments.Date, Assignments.Name, Assignments.Assignment, Assignments.[Start Time], Assignments.[End Time], Assignments.Items, Assignments.Notes
FROM Assignments
WHERE (((Assignments.Date) Between [Forms]![AdminWelcomeForm]![Start_Date_Edit] And [Forms]![AdminWelcomeForm]![End_Date_Edit]) AND ((Assignments.Name)=IIf([Forms]![AdminWelcomeForm]![EmployeeSelectorGrp]=1,[Name],[Forms]![AdminWelcomeForm]![NameSelectorEdit])) AND (([Forms]![AdminWelcomeForm]![txtQueryCriteria]) Like "*" & [Assignment] & "*"));
 

Uncle Gizmo

Nifty Access Guy
Staff member
Local time
Today, 07:34
Joined
Jul 9, 2003
Messages
16,333
In your "else statement" could you not just call another query that Returns all the records?
 

Users who are viewing this thread

Top Bottom