Joe,
 
    You wish to run a query with prameter input, with the feature that this parameter input should have the current year as its default value.
 
    The desired objective can be achieved by invoking the input box via user defined function. Sample query as well as the user defined function (Fn_SalesYear()) used there-in, are given below. T_Sales is the source table while SDate is date type field.
 
    Note - Similar results could be achieved by enclosing the parameter prompt within an IIf() statement. However, in such a case, the default value that is going to be actually used, does not get visually displayed.
 
Best wishes,
A.D.Tejpal
 
Sample Query
(Parameter with default value)
==================================
SELECT T_Sales.*
FROM T_Sales
WHERE (((Year([SDate]))=Fn_SalesYear()));
==================================
 
User Defined Function - Fn_SalesYear()
(Used in sample query above)
==================================
Function Fn_SalesYear() As Long
    Fn_SalesYear = Val(InputBox("Enter Sales Year " & _
                    "(Default = Current Year)", "Sales Year", _
                    Year(Date)))

End Function
==================================
 
----- Original Message -----
From: eliotchs
Sent: Monday, December 05, 2005 20:46
Subject: [AccessDevelopers] ? on Parametr query with a default value ??

Hi,

Does anyone know if it's possible to create a parameter query
with a default value.

Example:
I have a parameter asking for a year from a date field,
I would liek to have current year as a default.

Thanks
Joe



Please zip all files prior to uploading to Files section.




YAHOO! GROUPS LINKS




Reply via email to