Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 8
Default Type Mismatch Error when running a SELECT SQL

I am getting a Type Mismatch error (Error 13) occurring when I run the
following code. The Set rs statement is what is highlighted. The query
string works when I go into Design Query and paste it in the Edit SQL window.

With the exception of P_ID, all fields in the table are text fields. P_ID
is am AutoNumber field. When I display the query in a msgBox, There are no
quotes or tics around the value stored in strRecNo (as it should be). I have
used this same template for all the other select statements I am executing
with no problems.

Is there something I am missing? Any help would be appreciated.

TIA


Dim rs As Recordset

strProjectQuery = "SELECT P_FUND, P_BORG, P_NAME, P_2120, P_2125 " & _
"FROM Projects " & _
"WHERE P_ID=" & _
strRecNo & ";"

Set rs = CurrentDb().OpenRecordset(strProjectQuery)
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 811
Default Type Mismatch Error when running a SELECT SQL

Hi Andy,

If you declare your Recordset variable like this:

Dim rs As DAO.Recordset

Does that solve your problem? If so you most likely have the Microsoft
ActiveX Data Objects type library referenced in your project.

--
Rob Bovey, Excel MVP
Application Professionals
http://www.appspro.com/

* Take your Excel development skills to the next level.
* Professional Excel Development
http://www.appspro.com/Books/Books.htm

"Andy Dorph" wrote in message
...
I am getting a Type Mismatch error (Error 13) occurring when I run the
following code. The Set rs statement is what is highlighted. The query
string works when I go into Design Query and paste it in the Edit SQL
window.

With the exception of P_ID, all fields in the table are text fields. P_ID
is am AutoNumber field. When I display the query in a msgBox, There are
no
quotes or tics around the value stored in strRecNo (as it should be). I
have
used this same template for all the other select statements I am executing
with no problems.

Is there something I am missing? Any help would be appreciated.

TIA


Dim rs As Recordset

strProjectQuery = "SELECT P_FUND, P_BORG, P_NAME, P_2120, P_2125 " & _
"FROM Projects " & _
"WHERE P_ID=" & _
strRecNo & ";"

Set rs = CurrentDb().OpenRecordset(strProjectQuery)



Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Visual Basic Error Run Time Error, Type Mismatch Meg Partridge Excel Discussion (Misc queries) 12 September 10th 08 06:10 PM
Type mismatch error Petr Excel Programming 2 February 10th 05 07:24 AM
Why type mismatch - R/T error 13 Jim May Excel Discussion (Misc queries) 5 January 9th 05 06:45 PM
Befuddled with For Next Loop ------ Run - Time Error '13' Type Mismatch Error rdavis7408 Excel Programming 1 August 25th 04 03:54 AM
Type mismatch while running If statement Stel Excel Programming 4 December 18th 03 09:19 AM


All times are GMT +1. The time now is 05:44 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright ©2004-2025 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"