Your function only sees an argument, a VARIANT, probably (to handle null),
NOT A TABLE :
=============
Public Function DTable( argName AS Variant) AS Variant
...
...
...
DTable = ...
End Function
============
IN YOUR QUERY, NOT in your function definition, you use
===========
SELECT ... , DTable(tableName.ColumnName) , .... FROM tableName
===========
which has the effect to match the value in the said table, said column, to
the scalar value defined in your function definition.
BUT AGAIN, tableName.ColumnName must be reachable by your query, ie:
==========
SELECT tableName.ColumnName FROM tableName
==========
have to work, else, SELECT ..., DTable(tableName.ColumnName), ... FROM
tableName won't work either, because then the query would not be able to
'reach' the value to be send to the function, in the first place. The
problem won't be the function, in such case. BE SURE the query can reach the
value that will be used in your function, by using it in a query WITHOUT
using the function at all, exactly as in the last SQL statement I typed. I
repeat myself, THAT simple statement has to work, and you have to be sure it
works, without adding a call to your function.
Vanderghast, Access MVP
abkad said:
Ii want my function to be used in any access project not a particular one,
so
i don't want to specify tablename or column name on the function. i want
them
to be as variables and identify them on query like this Dtable ([table
name]![column name])
this how i wrote function on data base
--
ab
Michel Walsh said:
You must use Jet (not MS SQL Server).
You must use Access (not VB6, not Dot.Net, not Excel, ... )
The function must be in a standard module, NOT a class, form, report.
The function must be public (not private).
In the query, the argument of your function must exists. The following
statement:
SELECT tableName.ColumnName FROM tableName
should work, so, then, you can use
SELECT tableName.ColumnName, DTable(tableName.ColumnName) FROM
tableName
Vanderghast, Access MVP
abkad said:
Hi every body,
I want to creat general function on my access project. it is called
Dtable
(n). I will used it through one of my qeuries as Dtable
(
![column]).
but when i run query
it is promp to required data. How can i reference my function to
varaible
data access table