Mid function

E

enak

I am new to Access but am a very experienced vb programmer. I am using Access
2003. I have been given a database and asked to code some enhancements. I am
running into an error with the following code:

Set cnn = CurrentProject.Connection
rstApp.Open "Applicant", cnn, adOpenKeyset, adLockOptimistic, adCmdTableDirect
rstFilenum.Open "nextfilenum", cnn, adOpenKeyset, adLockOptimistic,
adCmdTableDirect

I get the error on the last line - rstFilenum.Open

Error message: Undefined function 'Mid' in expression.

Why am I getting this?

Thanks.
 
D

Douglas J Steele

nextfilenum must be a query that includes the Mid function.

I don't believe you can use VBA functions such as Mid when you're using ADO
to interact with the database.
 
E

enak

Great, Thanks for the info but how do I fix it? Everything works fine on the
Client's machine.
 
E

enak

I already did that. Everything looks fine. I am running it on my development
machine which is running Win2k3. Most of my development is in .net. I don't
know if this will make a difference.
 
R

Rob Oldfield

Can you open 'nextfilenum' directly on your machine? And what does the SQL
look like?
 
E

enak

Here is the query:

SELECT Max([file_num]) AS Nextfile_num
FROM Applicant
WHERE (Mid(Str([file_num]),Len([file_num])-2,2)=DatePart("m",Date()) OR
mid(str([file_num]),len([file_num])-1,1)=DatePart("m",Date())) AND
Right(Str([file_num]),2)=Right(Str(DatePart("yyyy",Date())),2);
 
R

Rob Oldfield

I'm with Doug that I'm surprised that that works on the client's machine.
What references are live on that machine?

And how are you handling the connection? Is this an adp or are you using
ODBC in some way?


enak said:
Here is the query:

SELECT Max([file_num]) AS Nextfile_num
FROM Applicant
WHERE (Mid(Str([file_num]),Len([file_num])-2,2)=DatePart("m",Date()) OR
mid(str([file_num]),len([file_num])-1,1)=DatePart("m",Date())) AND
Right(Str([file_num]),2)=Right(Str(DatePart("yyyy",Date())),2);

--
enak


Rob Oldfield said:
Can you open 'nextfilenum' directly on your machine? And what does the SQL
look like?


enhancements. I
am
 
E

enak

This is from one of my previous posts:

Set cnn = CurrentProject.Connection
--
enak


Rob Oldfield said:
I'm with Doug that I'm surprised that that works on the client's machine.
What references are live on that machine?

And how are you handling the connection? Is this an adp or are you using
ODBC in some way?


enak said:
Here is the query:

SELECT Max([file_num]) AS Nextfile_num
FROM Applicant
WHERE (Mid(Str([file_num]),Len([file_num])-2,2)=DatePart("m",Date()) OR
mid(str([file_num]),len([file_num])-1,1)=DatePart("m",Date())) AND
Right(Str([file_num]),2)=Right(Str(DatePart("yyyy",Date())),2);

--
enak


Rob Oldfield said:
Can you open 'nextfilenum' directly on your machine? And what does the SQL
look like?


I am new to Access but am a very experienced vb programmer. I am using
Access
2003. I have been given a database and asked to code some enhancements. I
am
running into an error with the following code:

Set cnn = CurrentProject.Connection
rstApp.Open "Applicant", cnn, adOpenKeyset, adLockOptimistic,
adCmdTableDirect
rstFilenum.Open "nextfilenum", cnn, adOpenKeyset, adLockOptimistic,
adCmdTableDirect

I get the error on the last line - rstFilenum.Open

Error message: Undefined function 'Mid' in expression.

Why am I getting this?

Thanks.
 
R

Rob Oldfield

Yes. I read that. And it can apply to various different connection
methods.

adp, mdb or what? What references are live on the machine that works?


enak said:
This is from one of my previous posts:

Set cnn = CurrentProject.Connection
--
enak


Rob Oldfield said:
I'm with Doug that I'm surprised that that works on the client's machine.
What references are live on that machine?

And how are you handling the connection? Is this an adp or are you using
ODBC in some way?


enak said:
Here is the query:

SELECT Max([file_num]) AS Nextfile_num
FROM Applicant
WHERE (Mid(Str([file_num]),Len([file_num])-2,2)=DatePart("m",Date()) OR
mid(str([file_num]),len([file_num])-1,1)=DatePart("m",Date())) AND
Right(Str([file_num]),2)=Right(Str(DatePart("yyyy",Date())),2);

--
enak


:

Can you open 'nextfilenum' directly on your machine? And what does
the
SQL
look like?


I am new to Access but am a very experienced vb programmer. I am using
Access
2003. I have been given a database and asked to code some enhancements. I
am
running into an error with the following code:

Set cnn = CurrentProject.Connection
rstApp.Open "Applicant", cnn, adOpenKeyset, adLockOptimistic,
adCmdTableDirect
rstFilenum.Open "nextfilenum", cnn, adOpenKeyset, adLockOptimistic,
adCmdTableDirect

I get the error on the last line - rstFilenum.Open

Error message: Undefined function 'Mid' in expression.

Why am I getting this?

Thanks.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top