Solved

How to call a module function in Access 2000 database using VB query recordset?

Posted on 2003-11-27
5
2,197 Views
Last Modified: 2012-06-21
Hi,
Here goes my code
-------------------------------------------------
Option Explicit
Dim Conn As New ADODB.Connection

Private Sub Form_Load()

    Conn.Provider = "Microsoft.Jet.OLEDB.4.0;Persist 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.
0
Comment
Question by:ssaravanamoorthy
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
5 Comments
 
LVL 10

Expert Comment

by:jobrienct
ID: 9833057
First of all are you aware that replace() is an internal function? try naming it something else and see if that clerars it up.

JOhn
0
 
LVL 8

Expert Comment

by:Benjamin_Luk
ID: 9834594
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
0
 
LVL 2

Expert Comment

by:dom_cath
ID: 9834686
To open an Access Function you do the following:

VariableYouWantDataReturnedInto = FunctionName(DataYouArePassingToTheFunction)

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
0
 
LVL 26

Accepted Solution

by:
Alan Warren earned 50 total points
ID: 9835729
Hi ssaravanamoorthy,

As far as I am aware functions internal to a Jet database are only exposed if  the application is loaded, therefor they are not able to be referenced by a connection.

Alan
0
 
LVL 2

Expert Comment

by:dom_cath
ID: 9967111
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
0

Featured Post

MS Dynamics Made Instantly Simpler

Make Your Microsoft Dynamics Investment Count  & Drastically Decrease Training Time by Providing Intuitive Step-By-Step WalkThru Tutorials.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
Email question 19 93
Return Data From Website in Access 6 58
Ranking Students in Ms Access based on given Criteria 5 60
Access 2010 Changing String to Date with Leading Zero 11 32
A simple tool to export all objects of two Access files as text and compare it with Meld, a free diff tool.
In Part II of this series, I will discuss how to identify all open instances of Excel and enumerate the workbooks, spreadsheets, and named ranges within each of those instances.
Familiarize people with the process of retrieving data from SQL Server using an Access pass-thru query. Microsoft Access is a very powerful client/server development tool. One of the ways that you can retrieve data from a SQL Server is by using a pa…
In Microsoft Access, learn different ways of passing a string value within a string argument. Also learn what a “Type Mis-match” error is about.

739 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question