Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

VBA functions in Queries

Status
Not open for further replies.

christopher007

Instructor
Nov 14, 2003
29
0
0
GB
Can I use a vba function that I have written in a query, im getting undifined function if i try this.
 
Hi!

I think you'll need declared it as public, and place it in a module (not a forms module - in VBE Insert | Module), then you should be able to call it the ususal way:

[tt]MyField: MyFunction([SomeFieldName])[/tt]

HTH Roy-Vidar
 
This 'approach' works for queries on the local (.MDB) recordsets, but may not be useable for other database engines (the 'Industrial Strength' db engines, such as SQL Server). Alos, RoyVidar's example does not show the full capability, as the Arglist "([SomeFieldName])" may be of any legal form for a function call -and MUST (of course) provide all of the required arguments of the function-, including multiple arguments and/or arrays. You should be aware, however, that providing a constant as the only argument to a calculated field for a recordset only instantiates the function for the FIRST record processed, as Ms. A. appears to 'optimize' the processing to eliminate the remainder of hte calls.




MichaelRed
m.red@att.net

Searching for employment in all the wrong places
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top