Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

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

Posted on 2003-11-27
5
Medium Priority
?
2,214 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
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 150 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

Free Tool: IP Lookup

Get more info about an IP address or domain name, such as organization, abuse contacts and geolocation.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

Did you know that more than 4 billion data records have been recorded as lost or stolen since 2013? It was a staggering number brought to our attention during last week’s ManageEngine webinar, where attendees received a comprehensive look at the ma…
If you’re using QODBC to update QuickBooks data from Microsoft® Access but Access is not showing the updated data, you could have set up QODBC incorrectly.
With Microsoft Access, learn how to specify relationships between tables and set various options on the relationship. Add the tables: Create the relationship: Decide if you’re going to set referential integrity: Decide if you want cascade upda…
Do you want to know how to make a graph with Microsoft Access? First, create a query with the data for the chart. Then make a blank form and add a chart control. This video also shows how to change what data is displayed on the graph as well as form…

783 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