+ Reply to Thread
Results 1 to 6 of 6

Public Function

  1. #1
    Registered User
    Join Date
    11-06-2007
    Posts
    48

    Public Function

    I use a built-in function in an Access db in some select qry's.

    From excel, i create an access qry, open the recordset, and then copy it to a specified range. This always works except for when i use this specific function in the sql string.

    Then i get a msg undefined function.
    Function being used is Nz()

    It does not seem like this should be an issue. Does anyone have any ideas.

    Thanks in advance.
    Last edited by jmicdk; 03-26-2008 at 10:32 PM.

  2. #2
    Forum Expert
    Join Date
    01-15-2007
    Location
    Brisbane, Australia
    MS-Off Ver
    2007
    Posts
    6,591
    Hi

    I'm pretty sure I've met this before and you can't use Access UDFs when running things from Excel.

    rylo

  3. #3
    Registered User
    Join Date
    03-24-2008
    Location
    Calabar, Nigeria
    MS-Off Ver
    2003, 2007
    Posts
    37
    It is true Nz is not a VBA function it is only visible to Access apps.

    Walkaround: Define your own Nz in your Excel project -

    Please Login or Register  to view this content.

  4. #4
    Registered User
    Join Date
    11-06-2007
    Posts
    48
    Thanks for the reply.

    Creating the function in Excel still results in an undefined function error.

    I know i can change this using a simple iif statement but the select qry is calling other queries also using Nz(). This means i would have to go back and change Nz everywhere to an iif statement. Very cumbersome.

    Even tried making a table by just executing the qry in access and not returning data to excel and then qry the table, but using querydefs("").execute also result in an error.


    Please Login or Register  to view this content.
    Any ideas helpfull.
    Thanks again
    Last edited by jmicdk; 03-27-2008 at 08:42 PM.

  5. #5
    Forum Expert
    Join Date
    01-15-2007
    Location
    Brisbane, Australia
    MS-Off Ver
    2007
    Posts
    6,591
    Hi

    Try creating the query in Access that includes your UDF. Then you may be able to bring the results from that query into your recordset. I think that was how I finally managed to get around it.

    See how that goes.

    rylo

  6. #6
    Registered User
    Join Date
    03-24-2008
    Location
    Calabar, Nigeria
    MS-Off Ver
    2003, 2007
    Posts
    37
    Sorry for the wrong turn, I checked my query files, all of them use the IIF function to replace the Access Nz function. I actually tried the UDF Nz and it failed.

    You have 2 options as I see it.

    1 is rylo's above. Except that in the case of Nz, the UDF is already defined in Access.

    2 is the spade work of replacing Nz with IIf VBA functions.

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1