Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 5838887
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 22, 20262026-05-22T11:30:57+00:00 2026-05-22T11:30:57+00:00

I need to be able to run a query such as SELECT * FROM

  • 0

I need to be able to run a query such as

SELECT * FROM atable WHERE MyFunc(afield) = "some text"

I’ve written MyFunc in a VB module but the query results in “Undefined function ‘MyFunc’ in expression.” when executed from .NET

From what I’ve read so far, functions in Access VB modules aren’t available in .NET due to security concerns. There isn’t much information on the subject but this avenue seems like a daed end.

The other possibility is through the CREATE PROCEDURE statement which also has precious little documentation: http://msdn.microsoft.com/en-us/library/bb177892%28v=office.12%29.aspx

The following code does work and creates a query in Access:

CREATE PROCEDURE test AS SELECT * FROM atable

However I need more than just a simple select statement – I need several lines of VB code.

While experimenting with the CREATE PROCEDURE statement, I executed the following code:

CREATE PROCEDURE test AS

Which produced the error “Invalid SQL statement; expected ‘DELETE’, ‘INSERT’, ‘PROCEDURE’, ‘SELECT’, or ‘UPDATE’.”

This seems to indicate that there’s a SQL ‘PROCEDURE’ statement, so then I tried

CREATE PROCEDURE TEST AS PROCEDURE

Which resulted in “Syntax error in PROCEDURE clause.”

I can’t find any information on the SQL ‘PROCEDURE’ statement – maybe I’m just reading the error message incorrectly and there’s no such beast. I’ve spent some time experimenting with the statement but I can’t get any further.

In response to the suggestions to add a field to store the value, I’ll expand on my requirements:

I have two scenarios where I need this functionality.

In the first scenario, I needed to enable the user to search on the soundex of a field and since there’s no soundex SQL function in Access I added a field to store the soundex value for every field in every table where the user wants to be able to search for a record that “soundes like” an entered value. I update the soundex value whenever the parent field value changes. It’s a fair bit of overhead but I considered it necessary in this instance.

For the second scenario, I want to normalize the spacing of a space-concatenation of field values and optionally strip out user-defined characters. I can come very close to acheiving the desired value with a combination of TRIM and REPLACE functions. The value would only differ if three or more spaces appeared between words in the value of one of the fields (an unlikely scenario). It’s hard to justify the overhead of an extra field on every field in every table where this functionality is needed. Unless I get specific feedback from users about the issue of extra spaces, I’ll stick with the TRIM & REPLACE value.

My application is database agnostic (or just not very religious… I support 7). I wrote a UDF for each of the other 6 databases that does the space normalization and character stripping much more efficiently than the built-in database functions. It really annoys me that I can write the UDF in Access as a VB macro and use that macro within Access but I can’t use it from .NET.

I do need to be able to index on the value, so pulling the entire column(s) into .NET and then performing my calculation won’t work.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-22T11:30:58+00:00Added an answer on May 22, 2026 at 11:30 am

    I think you are running into the ceiling of what Access can do (and trying to go beyond). Access really doesn’t have the power to do really complex TSQL statements like you are attempting. However, there are a couple ways to accomplish what you are looking for.

    First, if the results of MyFunc don’t change often, you could create a function in a module that loops through each record in atable and runs your MyFunc against it. You could either store that data in the table itself (in a new column) or you could build an in-memory dataset that you use for whatever purposes you want.

    The second way of doing this is to do the manipulation in .NET since it seems you have the ability to do so. Do the SELECT statement and pull out the data you want from Access (without trying to run MyFunc against it). Then run whatever logic you want against the data and either use it from there or put it back into the Access database.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I need to be able to run an Oracle query which goes to insert
I have an app that normal users need to be able to run, but
I need to be able to run RegLoadKey() on a remote machine, and it
What exactly does a mobile need to be able to run JavaFX? Can it
In order to create the proper queries I need to be able to run
I need to be able to determine at run time what compilation options were
I need to be able to specify a command to run when the SelectionChanged
Summary: I want to be able to run a query against an external database
I need to pull a query like this one $result = mysql_query( SELECT id,
Users of the website need to able to store images in their area ,

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.