SmokeEater
Technical User
I have a query
As you can see I am trying to get the criteria from the form frmReportOptions. The field ctlPrepTypeResult is populated from a listbox afterupdate.
The query works if I manually populate it. Help !!
Code:
SELECT tblPrepTime.Course, tblPrepTime.Instructor, tblPrepTime.Type_Of_Prep, tblPrepTime.Date, tblPrepTime.Time, tblCourseInfo.Course_Name, tblCourseInfo.[Start Date], tblCourseInfo.[End Date]
FROM tblPrepTime INNER JOIN tblCourseInfo ON tblPrepTime.Course = tblCourseInfo.Course_No
WHERE (((tblPrepTime.Type_Of_Prep)=[Forms]![frmReportOptions]![ctlPrepTypeResult]));
As you can see I am trying to get the criteria from the form frmReportOptions. The field ctlPrepTypeResult is populated from a listbox afterupdate.
Code:
Private Sub ctlPrepType_AfterUpdate()
On Error GoTo Err_ctlPrepType_AfterUpdate
Dim strWhere As String, varItem As Variant
Dim gstrWhereBook As String
If Me!ctlPrepType.ItemsSelected.Count = 0 Then
Me!ctlPrepTypeResult = "*"
Exit Sub
End If
For Each varItem In Me!ctlPrepType.ItemsSelected
strWhere = strWhere & Chr$(34) & Me!ctlPrepType.Column(0, varItem) & Chr$(34) & ","
Next varItem
strWhere = Left$(strWhere, Len(strWhere) - 1)
gstrWhereBook = "In (" & Trim(strWhere) & ")"
If IsNull(strWhere) Then gstrWhereBook = "*"
Me!ctlPrepTypeResult = Trim(gstrWhereBook)
Me!ctlPrepTypeResult.Requery
Exit_ctlPrepType_AfterUpdate:
Exit Sub
Err_ctlPrepType_AfterUpdate:
MsgBox Err.Description
Resume Exit_ctlPrepType_AfterUpdate
End Sub
The query works if I manually populate it. Help !!