Home  Fees/Services  Microsoft Access Templates  Tutorials  Access Download  Articles  Search  Contact  Privacy  Links

Access VBA Tutorial
   
Access Programming Examples & Code Samples

Recordset Filter Methods Visual Basic Tutorials, Workarounds & Solutions for VB6
Form Filter in Access Visual Basic




VBA Tutorials:
Access to Google Earth
VB6 Age Calculation
Change Case VBA
VBA Email via Gmail
VBA Outlook Email
Read Email Access
RTF Report Email
Send Outlook Email Access
Calculate Running Sum
Concatenate Records
VBA Stock Quotes
VBA CreateQueryDef
Database Path Solution
Detail-Master Update
Field Validation VBA
Field Value New-Old
FindFirst Recordset
Get Version Number
VB6 Global Parameters
VBA Global Variables
Labels as Links
List Box Files List
VBA Mail Merge
OutputTo Crosstab
Sort Recordset Trick
VBA Recordset Filters
Reference Form Field
VBA Select Case
Transaction Processing

Visual Basic Function Examples


VB Recordset Filter for Dynamic Recorsets

There are basically three techniques used to dynamically filter an Access Visual Basic recordset that is continuous on a form.

  • Filter recordset manually using the toolbar

  • Filter VB recordset using VBA with a text field or combo box

  • Use a parameter query that read the value of a text field or combo box to filter recordset


Here we will show you how to dynamically filter a continuous recordset in Visual Basic on a form.  Below is the form with which we will be working:


Our goal is to use the Store_Selection combo box to filter the records in the form.  These recordsets refer to sales and deliveries of bait to a store.  We use the Visual Basic AfterUpdate trigger on the property sheet of the combo box.  (note:  there is a similar subroutine for the Year field).  Here is the VBA code:

Private Sub Store_Selection_AfterUpdate()

Forms![$mainmenu]![F_History_By_Store_Final].Form.Filter = & _
"Store_ID=" & Me.Store_Selection.Column(0) & _
" and year=" & Chr(34) & Me.Year_Selection & Chr(34)

Form_F_History_By_Store_Final.Form.FilterOn=True

End Sub

Whenever the user selects a new store number the form immediately displays the new filtered record set.  You can add text boxes and combo boxes to filter on any combination of fields in the recordset.  The Chr(34) is my way of putting in the double quote marks for character variables.








Have errors?  No doubt we can answer your question quickly and easily.  Simple questions get simple answers at no charge via email.




Popular Database Templates:

HOA/Homeowner Association Database Template

Loan Process Management Access Templates

Student Loan/Grant Control Access Templates




Contact Information

VBA runtime tips tricks fix solution

Access Visual Basic/VBA/VBScript/VB6 Tutorials
Visual Basic Error Fix & Problem Solutions