[AccessD] Ambiguous Nmae in Query Expression

Ken Ismert KIsmert at TexasSystems.com
Thu Apr 13 12:18:53 CDT 2006


Chester,

> ... First point - avoid variants wherever possible. 
> Try defining D and the function as dates ... 

While good programming practice for regular VB coding, keep the Variant
type in this case. Access Query columns always have type Variant, so
functions that are meant to be used with queries should have all
parameters defined as Variant, too. 

> ... Try a dot instead of a bang in [ProdPattern]![Date] ...

Unlikely to help. Its just two ways of saying the same thing. (I use
dot)

> ... Declare the function as Static ... 

While Static can help improve the performance of functions written for
use with queries, it won't solve your error message. But just to be
extra explicit, you can use: 

   Public Static Function DaysInMonth2(ByRef D As Variant)

Since you tried the function in the module and it worked fine, you
probably don't have a duplicate function definition. 

You still have a reserved word in your query: [qry Pattern Days on
Injection by Fluid].Date. The Date function is syntactically valid
without the ending (). When you introduced the DaysInMonth2() function
in your query, Access looked for other function calls, and couldn't
decide whether Date was a function or a field. Thus, the ambiguous name
error. 

Never use field names that are the same as any VB built-in functions or
SQL reserved words. I use compound field names, like 'ProdDate' or
'PatternDate', to ensure that all field names are unique from any
reserved words. 

-Ken



More information about the AccessD mailing list