Something different for Date variables?

  • Thread starter Thread starter Leslie Coover
  • Start date Start date
L

Leslie Coover

Note the following Query Field names associated with functions:

IDX_:IDX([ID])

Function IDX(ID As String)
IDX = ID
End Function

DD_:DD([Date_Bought])

Function DD(Date_Bought As Date)
DD = Date_Bought
End Function

IDX_:IDX([ID]) works as expected

but

DD_:DD([Date_Bought])

returns the error message:

"The expression you entered has a function containing the wrong number of
arguments"

When functions involve date variables do we do something extra?

Thanks!!
 
No. Nothing special needed for date variables.

Could the Date_Bought field be Null?
If so, the call to Date_Bought will fail due to an invalid use of Null.
The only VBA data type that can be Null is Variant, so you would need to
use:
Function DD(Date_Bought As Variant)

If that doesn't solve the problem, try a different alias, e.g.:
DD1: DD([Date_Bought])

Whenever Access misundertands names, uncheck the boxes under:
Tools | Database Utilities | General | Name AutoCorrect
Explanation of why:
http://allenbrowne.com/bug-03.html

Of course, functions are not needed at all for these simple operations, but
presumably these examples are just to show up the problem.
 
Back
Top