Create an in-line user-defined function
Microsoft Access adds the in-line user-defined function to Queries under Objects in the Database window.
Create a table user-defined function
Access displays the SQL Text Editor with the following skeleton SQL syntax:
CREATE FUNCTION "Function1"
(
/*
@parameter1 datatype = default value,
@parameter2 datatype
*/
)
RETURNS /* @table_variable TABLE (column1 datatype, column2 datatype) */
AS
BEGIN
/* INSERT INTO @table_variable
sql select statement */
/* alternative sql statement or statements */
RETURN
END
Write the table user-defined function by using Transact-SQL. For more information on Transact-SQL, see the SQL Server documentation.
Microsoft Access adds the table user-defined function to Queries under Objects in the Database window.
Note You can graphically edit an SQL SELECT statement in a table user-defined function by using the Query Builder.
Create a scalar user-defined function
Access displays the SQL text editor with the following skeleton SQL syntax.
CREATE FUNCTION "Function1"
(
/*
@parameter1 datatype = default value,
@parameter2 datatype
*/
)
RETURNS /* datatype */
AS
BEGIN
/* sql statement ... */
RETURN /* value */
END
Write the scalar user-defined function by using Transact-SQL. For more information on Transact-SQL, see the SQL Server documentation.
Microsoft Access adds the scalar user-defined function to Queries under Objects in the Database window.
Note You can graphically edit an SQL SELECT statement in a scalar user-defined function by using the Query Builder.
Note You cannot use a user-defined function as the record source of a data access page.