How do you write a custom function in access vb that is available in expression builder ?

Posted on 2004-11-25
Last Modified: 2012-05-05
I would like to write a function in vb that is easily accessible from expression builder for a given query.
ie.  if my function in access vb is called myFunc ()  and takes a string and reverses the letters.
I would like to call the function from expression builer like the built in functions - eg. left(dbcolum,3)  
Ideally i would like to call myFunc(dbcolumn) and this would return that field with the letters reversed.

The above is only and example - please dont tell me there is a built in function that reverseres strings.

Thanks in advance
Question by:richardp1971
    1 Comment
    LVL 26

    Accepted Solution

    You just need to make the function Public in a classic VBA module

    Public Function StrReverse(strIn as string) as String
       'function code goes here
       StrReverse= 'computed string
    End Function

    Now you can use it in your SQL

    Select StrReverse(yourcolumn) from yourtable

    Write Comment

    Please enter a first name

    Please enter a last name

    We will never share this with anyone.

    Featured Post

    How to run any project with ease

    Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
    - Combine task lists, docs, spreadsheets, and chat in one
    - View and edit from mobile/offline
    - Cut down on emails

    Entering time in Microsoft Access can be difficult. An input mask often bothers users more than helping them and won't catch all typing errors. This article shows how to create a textbox for 24-hour time input with full validation politely catching …
    This article explains all about SQL Server Piecemeal Restore with examples in step by step manner.
    Video by: Steve
    Using examples as well as descriptions, step through each of the common simple join types, explaining differences in syntax, differences in expected outputs and showing how the queries run along with the actual outputs based upon a simple set of dem…
    Polish reports in Access so they look terrific. Take yourself to another level. Equations, Back Color, Alternate Back Color. Write easy VBA Code. Tighten space to use less pages. Launch report from a menu, considering criteria only when it is filled…

    761 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

    12 Experts available now in Live!

    Get 1:1 Help Now