ADO Data Control Error:Undefined function "Function Name" in Expression

Posted on 2006-03-29
Last Modified: 2008-01-09
I have an MS Access database and I added a module. In the module I wrote a code that will round up time to the nearest hour. The function works in my queries in MS Access but when I set the recordsource of ADO Data Control in Visual Basic, I get an error message: Undefined function 'RoundUpTime' in expression. What seems to be the problem? And How would I fix it?
Question by:blue_bird
    LVL 15

    Expert Comment

    Undefined function 'RoundUpTime' in expression indicates that the code is unable to find the function named 'RoundUpTime' in the form or module you are using it in. I'm not sure how you are defining your function, but you could try to change this
    Private Function RoundUpTime
    Public Function RoundUpTime

    This will allow the module to be seen throughout the program
    LVL 11

    Accepted Solution

    It's because the RoundUpTime function exists in your access mdb and you are trying to use it through ado which isn't possible as far as I know.  Return the field in your query as it is in the mdb and create a function in visual basic that will round it up when required.
    LVL 5

    Expert Comment

    Hi Blue_Bird,

    Leclairm is right. ADO Cannot execute the VB code within the database, because that code isn't part of the Jet drivers. You can only call default functions supported by Access, like Left, Right, Mid, IsNull, InStr, Sum, Min, Max, Count, etc. I agree with leclairm that you should return the normal time value, and round it afterwards in your VB code.

    Please don't accept this comment as an answer... Leclairm came first. I'm just posting because you might want a second opinion on this.
    LVL 5

    Expert Comment

    Hi Dan,

    I believe Leclairm gave the right solution. I believed he was right, so I created a test case just to be sure. The test turned out that Leclair IS right. He also gave a possible workaround, to which Blue_Bird hasn't responded. This answers both Blue_Bird's questions.



    Write Comment

    Please enter a first name

    Please enter a last name

    We will never share this with anyone.

    Featured Post

    Top 6 Sources for Identifying Threat Actor TTPs

    Understanding your enemy is essential. These six sources will help you identify the most popular threat actor tactics, techniques, and procedures (TTPs).

    Introduction I needed to skip over some file processing within a For...Next loop in some old production code and wished that VB (classic) had a statement that would drop down to the end of the current iteration, bypassing the statements that were c…
    Introduction While answering a recent question ( in the VB classic zone, I wrote some VB code in the (Office) VBA environment, rather than fire up my older PC.  I didn't post completely correct code o…
    Get people started with the process of using Access VBA to control Outlook using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Microsoft Outlook. Using automation, an Access applic…
    This lesson covers basic error handling code in Microsoft Excel using VBA. This is the first lesson in a 3-part series that uses code to loop through an Excel spreadsheet in VBA and then fix errors, taking advantage of error handling code. This l…

    760 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

    Need Help in Real-Time?

    Connect with top rated Experts

    7 Experts available now in Live!

    Get 1:1 Help Now