Question Adding a User Defined Function (1 Viewer)

lynxbci

Registered User.
Local time
Today, 05:10
Joined
Nov 27, 2007
Messages
73
Hi,
I have written a couple of functions and wanted to know how i add them into Access. I have gone into VB area and created a module and pasted the function code into there, but when i am using build in a query my function is not listed. There are other user defined functions showing (created previously).

For info the code is as follows :- (this function works)

Public Function Scode(oSt As String)
Dim all As String, C As Integer, T As Integer
Do Until C = 3
T = T + 1
all = all & Mid(oSt, T, 1)
If IsNumeric(Mid(oSt, T, 1)) Then
C = C + 1
End If

If T = Len(oSt) Then Exit Do
Loop
Scode = all
End Function


In summary what is the procedure for adding a user defined function to Access?

Thanks
 

DCrake

Remembered
Local time
Today, 05:10
Joined
Jun 8, 2005
Messages
8,632
If your module name does not conflict with any user defined functions you should not have a problem. However, in your queries you need to refer to them manually as they are not automatically addedd to the Access UDF container.

For example, create a new column in your query and enter the following:

UDFS:Scode([YourFieldName])

NOTE:Your function accepts parameters but does not return a value you need to revise your function as such:

Public Function Scode(oSt As String) As String

David
 

Users who are viewing this thread

Top Bottom