

Depending on the filtering needed, one or another of these row source types is appropriate.

There are basically three types of row source queries: (1) a value list, where the values to be selected are typed into the Row Source property of the combo box (2) a table/query row source, with a lookup table (or a query based on the table) as the row source and (3) a table/query row source, with a query based on a main table, set to display unique values for the field used for filtering. LngCount = CreateAndTestQuery(strQuery, strSQL)ĭebug.Print "No. StrSQL = "SELECT * FROM qryWorkSchedule WHERE " & pstrFilter & " "ĭebug.Print "SQL for " & strQuery & ": " & strSQL 'Save filter to a custom property for use in reportĬall SetProperty(strPropertyName, lngDataType, _ PstrFilter = Left(pstrFilter, Len(pstrFilter) - 5) & IIf(pstrStatusFilter "", pstrStatusFilter, "") & IIf(pstrStartDateFilter "", pstrStartDateFilter & " And ", "") _ & IIf(pstrProjectCodeFilter "", pstrProjectCodeFilter & " And ", "") _ & IIf(pstrTechnicianFilter "", pstrTechnicianFilter & " And ", "") _ PstrFilter = IIf(pstrLocationFilter "", pstrLocationFilter _ The CreateFilter procedure concatenates the filters (only those with selected values), and calls the CreateAndTestQuery to create and save a filtered query, which is the record source of the rptWorkScheduleFiltered report: PstrStartDateFilter = " = " & Chr(35) _ĭebug.Print "Start Date filter: " & pstrStartDateFilter
#OFFICE FOR MAC 2016 COMBOBOX ROWSOURCE CODE#
PstrProjectCodeFilter = " = " & lngProjectCodeĭebug.Print "Project Code filter: " & pstrProjectCodeFilter & " in " & Me.ActiveControl.Name & " procedure " _ PstrLocationFilter = " = " & Chr(39) _ĭebug.Print "Location filter: " & pstrLocationFilter 'Save value to public variable for use in report filter query When an item is selected in a combo box, a public String variable is set with a filter string, using the appropriate delimiters: Text Value

Finally, the Open Report button opens the report in print preview. The Clear Selections button clears all the selections and sets the report type to All. The number of records found for the filter is displayed in the # Records textbox, and the Filtered option is selected in the Report Type option group. The filter is concatenated every time a selection is made, and displayed in the Filter textbox. The filter form in the sample database (Filter by Form (AA 248).accdb) has five combo box selectors used to select values for filtering a report (you can also print an unfiltered report).
#OFFICE FOR MAC 2016 COMBOBOX ROWSOURCE HOW TO#
The row sources can be of three types this article discusses how to select the appropriate type of row source query, and use them to open a filtered report. IntroductionĬombo boxes are a handy way to select values for various purposes, such as filtering forms and reports. Thanks for joining us! You'll get a welcome message in a few moments.
