ssaravanamoorthy
asked on
How to call a module function in Access 2000 database using VB query recordset?
Hi,
Here goes my code
-------------------------- ---------- ---------- ---
Option Explicit
Dim Conn As New ADODB.Connection
Private Sub Form_Load()
Conn.Provider = "Microsoft.Jet.OLEDB.4.0;P ersist Security Info=False;Data Source=C:\windows\desktop\ db2.MDB"
Conn.Open
Dim adors As New ADODB.Recordset
adors.Open "SELECT empno from table1 where replace(ucase(dept),' ','')='SW'", Conn, adOpenForwardOnly, adLockReadOnly
End sub
I have written a function named "replace" as public function in Access database module. I get error as undefined 'replace' function. How to solve this problem?
Thanks in advance.
Moorthy.
Here goes my code
--------------------------
Option Explicit
Dim Conn As New ADODB.Connection
Private Sub Form_Load()
Conn.Provider = "Microsoft.Jet.OLEDB.4.0;P
Conn.Open
Dim adors As New ADODB.Recordset
adors.Open "SELECT empno from table1 where replace(ucase(dept),' ','')='SW'", Conn, adOpenForwardOnly, adLockReadOnly
End sub
I have written a function named "replace" as public function in Access database module. I get error as undefined 'replace' function. How to solve this problem?
Thanks in advance.
Moorthy.
Please Delete 'Private' at the head of your function code, and add 'Public' at the begin of your code like:
Public Function Replace()
.........'Code
End Function
Regards
Ben
Public Function Replace()
.........'Code
End Function
Regards
Ben
To open an Access Function you do the following:
VariableYouWantDataReturne dInto = FunctionName(DataYouArePas singToTheF unction)
eg
CurCostIncludingTax = CalcTax(CurCost)
If you are not expecting data back from the function then it is not a function but a sub. Rename the Function to a sub and call it.
Call CalcTax(CurCost)
Dom
VariableYouWantDataReturne
eg
CurCostIncludingTax = CalcTax(CurCost)
If you are not expecting data back from the function then it is not a function but a sub. Rename the Function to a sub and call it.
Call CalcTax(CurCost)
Dom
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
I know this is closed but if it help no you cannot ref functions externally but you can ref macros. And a macro can run a function.
Dom
Dom
JOhn