UtterAccess HomeUtterAccess Wiki

Welcome Guest ( Log In | Register )

Custom Search
Edit Discussion
> GetQueryCriteria    

This function provides an alternative approach to setting query criteria at run-time. Instead of having the criteria refer to a control on an open form or subform, you can save the criteria to memory by calling GetQueryCriteria with the actual criteria value as its argument. The in the query, use a call to the function without argument.

The code here is a template for production code which will have to be tailored for data type.


Public Function GetQueryCriteria(Optional TheDate) As Date
' Code courtesy of UtterAccess Wiki
' http://www.utteraccess.com/wiki/index.php/Category:FunctionLibrary
' Original submission by Glenn Lloyd
'based on a code snippet by MVP and UA VIP John Spencer
' Date contributed August 5, 2010
' Description: set/get query criteria value

' You are free to use this code in any application,
' provided this copyright notice is left unchanged.
   Const cstrProcedure = "GetQueryCriteria"
   Dim strMsg As String
   Static dteStart As Date
   On Error GoTo HandleError
   If Not IsMissing(TheDate) Then
       dteStart = TheDate
   'display error message if value has not yet been assigned
       If dteStart = CDate(0) Then
           strMsg = "Function " & cstrProcedure & " has not been initialized."
           MsgBox strMsg, vbOKOnly + vbCritical, "No value"
       End If
   End If
   GetQueryCriteria = dteStart
   Exit Function


   strMsg = "Error " & Err & " in procedure " & cstrProcedure
   MsgBox strMsg, vbOKOnly + vbCritical, "Procedure Error"
   Resume HandleExit
End Function

Creative Commons License
GetQueryCriteria by UtterAccess Wiki is licensed under a Creative Commons Attribution-ShareAlike 3.0 Unported License.
Editing and revision of the content is freely encouraged; for details, see Expected Usage.

Edit Discussion
Custom Search

Thank you for your support!
This page has been accessed 5,022 times.  This page was last modified 09:36, 6 April 2011 by Jack Leach. Contributions by Glenn Lloyd  Disclaimers