Qry not updating from form dating for felons

DCount is one of Access' collection of Domain Aggregate functions (others include DSum, DMax, DMin, DLookup etc.) that are used to extract summary information from a recordset.They all work more-or-less the same way and take two or three arguments, for example: =DCount (Expression, Domain, [Criteria]) The Expression is usually the name of the field whose entries you are interested in.* * Neither the name of APress nor the names of its contributors * may be used to endorse or promote products derived from this software * without specific prior written permission.* * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR * A PARTICULAR PURPOSE ARE DISCLAIMED.For an unfiltered recordset all you need to do is create a VBA statement which uses DCount to calculate the number of records and write it into the textbox.If you attach this statement to the form's On Current event the value will be updated when the form is opened, and when each new record is displayed.In this example the Control Source of the textbox uses the values in two combo boxes (named cbo Office and cbo Department) included in the expression: =DCount("[Staff ID]","tbl Staff","[Office]='" & [cbo Office] & "' AND [Department]='" & [cbo Department] & "'") Using DCount this way is easy but it has its disadvantages.If the number of records in the recordset changes, perhaps because the user adds or deletes records, the value shown in the textbox is not automatically recalculated.

This process requires some VBA code to read the values chosen by the user and construct an SQL WHERE clause.

This is then applied to the form's Filter property.

When the code then sets the form's Filter On property to True the form displays a filtered recordset.

var microsoft = microsoft

Leave a Reply