Undefined function 'mid' in expression in MS Access - ms-access

I am trying to write a query in MS Access, and receiving the error "Undefined function 'mid' in expression' when I try to execute it.
SELECT MID([ColumnName], 4,2)
FROM tblName
As I understand it, the MID function is the MS Access equivalent to Substring. Both the table and the column definitely exist. What could be causing this error?

Check 'References' in 'Tools' menu in VBA, there must be some 'MISSING' libraries.

Related

I was trying to concatenate 3 columns in SQL from dbvisualizer

I was trying to concatenate 3 columns in SQL, but I getting error message as
1) [Error Code: -440, SQL State: 42884] DB2 SQL error: SQLCODE:
-440, SQLSTATE: 42884, SQLERRMC: CONCAT;FUNCTION. 2) [Error Code: -727, SQL State: 56098] DB2 SQL error: SQLCODE: -727, SQLSTATE: 56098, SQLERRMC: 2;-440;42884;CONCAT|FUNCTION
This is my query
select concat(number,ID,name) as MemberDetails from Member where number = '123'
This looks like a problem with the schema. Specifically, it involves functions and procedures.
You have two SQL return codes, both of which are errors. The two codes are
-440: Routine &1 in &2 not found with specified parameters. A function or procedure with the specified name and compatible arguments was not found
and
-727: There actually isn't an error code named this. Did you mean -747?
In SQL, a negative number represents an unsuccessful call with an error.
You need a separate alias name. Also you might want to add the alias before the column name just in case there's disambiguation. Here's what it should look like.
select concat(number,ID,name) as M from Member where M.number = '123'
If neither of them worked, it is a problem with the SCHEMA, not with the above query.

Invalid descriptor index on LAST_INSERT_ID after insert

Strange situation with my ODBC code ( called from a C library ). Basically, I have the following sequence of events:
Create insert statement ( just a string )
Call SQLPrepare with that insert statement string
Bind the various parameters ( column values ), using
SQLBindParameter
Call SQLExecute to insert the row ( this works, by the way, as I can
see the row in the MySQL DB )
Create "select last_insert_id()" statement string
NOTE: if in SQL Server mode, we would create a "select ##identity"
statement
Bind column using SQLBindCol - this is where I get the "Invalid
descriptor index" error
NOTE: if in SQL Server mode, this works fine, with no error
Call SQLExecDirect to get the last insert id - this never happens
because of SQLBindCol error
Does the standard MySQL ODBC connector require something special in this situation? Does anyone have an ODBC example of this type of "insert" then "get last insert id" behavior? Maybe I need to call "SQLPrepare" before step 6 ( where I bind the column )? Another way to ask this: Should there be an SQLPrepare call for each SQLExecute or SQLExecDirect call?
I know it works directly in SQL, so the problem is my C ODBC code.
Thanks.
For those who are interested, I ended up changing the above steps by adding an SQLPrepare call between creating the "select last_insert_id()" ( step 5 ) and calling SQLBindCol ( step 6 ). Not sure if that would work for others, but it seems to be working rather well for me.
As for research, I looked all over the place online and never found a really good or clear answer. Most comments were about the SQL involved, not ODBC. And the references to ODBC were vague and did not seem to apply to my situation, from what I could see.
My assumption is that the SqlServer ODBC driver I am using handles the missing prepare statement differently ( maybe even better, but that is debatable ) than my MySql ODBC driver.
SQL Server ODBC driver was the one provided by Easysoft
MySql ODBC driver was the one provided with the standard CentOS install of MySql
Hopefully this will help people. Obviously, if people have a better idea, please tell us.

JdbcOdbc Driver Fails to Find the Replace Function in MS Access

Good people,
I am trying to execute an SQL query against an MS Access database through my Java program. The program uses the JdbcOdbc driver. The query contains the inbuilt Replace function in it. It looks something like this:
SELECT Replace(first_name, '-', ' ') AS f_name FROM patient WHERE....
The program fails with the following error: "[Microsoft][ODBC Microsoft Access Driver] Undefined function 'Replace' in expression."
How can this be? Other functions such as LCase and Trim work just fine. Also, the Replace function works okay when executed directly on the back end.
Your query can not use the Replace() function unless it is run from within an Access session.
The situation is the same as if you were attempting to use a user-defined function. The db engine can only utilize those with assistance from the Access expression service, which is only available from within an Access session.

Invalid Procedure Call on DateDiff with MS Access Driver

The following query:
SELECT DateDiff('month',0,'2000-01-01 00:00:00');
Returns a "[ODBC Microsoft Access Driver] Invalid procedure call" error, with the bizarre code of 22018.
Specs:
Microsoft Access Driver version: 4.00.6305.00
Database created with Access 2003
The above appears to be the proper syntax, as calling the function with the current format (no single quotes for month), returns "[Microsoft][ODBC Microsoft Access Driver] Too few parameters. Expected 1."
So, what is the proper syntax, if I did not get it right? Alternatively, how do I perform a datediff with that version of the driver?
I don't understand how ODBC is involved, but your query won't work in a pure Access context because DateDiff requires "m" as the interval argument for month.
Within Access 2003, this query returns 1201:
SELECT DateDiff('m',0,'2000-01-01 00:00:00');

Excel to access

With respect to below macro. Which VB Reference setting I have to do for run this macro.
As I got error "Run-time error '-2147217900 (80040e14)':
Syntax error in From clause.
Updating MS - Access fields through MS-Excel cells
kindly guide.......
To use ADO stuff you have to add the below to your references:
Microsoft ActiveX Data Objects x.x Object Library
As for the syntax error, perhaps pasting some code and telling us which line the debugger says is erroring out on would help. My initial guess is some sort of select statement that is selecting something that doesn't exist -- but without code/intent/example data it would be hard to pinpoint.