473,385 Members | 1,796 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,385 software developers and data experts.

Type Mismatch Error in Recordset Where Clause

Why do I receive a Type mismatch error when running the following
code, which has a SQL Server 2000 back end database?
The error occurs on the following line: Set rs = db.OpenRecordset(SQL,
dbOpenDynaset)
>
Dim db As DAO.Database
Dim rs As DA0.Recordset
Dim SQL As String
Dim CountRecs As Long

Set db = CurrentDb()

SQL = "SELECT tblProduct.ProductCode, tblProduct.Description "
SQL = SQL & "FROM tblProduct WHERE tblProduct.[ProductCode]=' " &
Me!
cboProductCode & " ' "

Set rs = db.OpenRecordset(SQL, dbOpenDynaset)
rs.Open
CountRecs = rs.RecordCount
<

Feb 15 '07 #1
4 4878
On Feb 15, 5:42 pm, "tomleb...@msn.com" <tomleb...@msn.comwrote:
Why do I receive a Type mismatch error when running the following
code, which has a SQL Server 2000 back end database?
The error occurs on the following line: Set rs = db.OpenRecordset(SQL,
dbOpenDynaset)

Dim db As DAO.Database
Dim rs As DA0.Recordset
Dim SQL As String
Dim CountRecs As Long

Set db = CurrentDb()

SQL = "SELECT tblProduct.ProductCode, tblProduct.Description "
SQL = SQL & "FROM tblProduct WHERE tblProduct.[ProductCode]=' " &
Me!
cboProductCode & " ' "

Set rs = db.OpenRecordset(SQL, dbOpenDynaset)
rs.Open
CountRecs = rs.RecordCount
<

This may be obvious, but is the ProductCode field a string type?

Feb 16 '07 #2
On Feb 15, 5:42 pm, "tomleb...@msn.com" <tomleb...@msn.comwrote:
Why do I receive a Type mismatch error when running the following
code, which has a SQL Server 2000 back end database?
The error occurs on the following line: Set rs = db.OpenRecordset(SQL,
dbOpenDynaset)

Dim db As DAO.Database
Dim rs As DA0.Recordset
G0od 1

James A. Fortune
CD********@FortuneJames.com

Feb 16 '07 #3
On Feb 15, 4:52 pm, "storrboy" <storr...@sympatico.cawrote:
On Feb 15, 5:42 pm, "tomleb...@msn.com" <tomleb...@msn.comwrote:


Why do I receive a Type mismatch error when running the following
code, which has a SQL Server 2000 back end database?
The error occurs on the following line: Set rs = db.OpenRecordset(SQL,
dbOpenDynaset)
Dim db As DAO.Database
Dim rs As DA0.Recordset
Dim SQL As String
Dim CountRecs As Long
Set db = CurrentDb()
SQL = "SELECT tblProduct.ProductCode, tblProduct.Description "
SQL = SQL & "FROM tblProduct WHERE tblProduct.[ProductCode]=' " &
Me!
cboProductCode & " ' "
Set rs = db.OpenRecordset(SQL, dbOpenDynaset)
rs.Open
CountRecs = rs.RecordCount
<

This may be obvious, but is the ProductCode field a string type?- Hide quoted text -

- Show quoted text -
The ProductCode is text in a combo box, which I assume is a string.
Should another argument follow dbOpenDynaset because this is an SQL
Server database.

Feb 16 '07 #4
On Feb 16, 1:09 am, "tomleb...@msn.com" <tomleb...@msn.comwrote:
On Feb 15, 4:52 pm, "storrboy" <storr...@sympatico.cawrote:
On Feb 15, 5:42 pm, "tomleb...@msn.com" <tomleb...@msn.comwrote:
Why do I receive a Type mismatch error when running the following
code, which has a SQL Server 2000 back end database?
The error occurs on the following line: Set rs = db.OpenRecordset(SQL,
dbOpenDynaset)
Dim db As DAO.Database
Dim rs As DA0.Recordset
Dim SQL As String
Dim CountRecs As Long
Set db = CurrentDb()
SQL = "SELECT tblProduct.ProductCode, tblProduct.Description "
SQL = SQL & "FROM tblProduct WHERE tblProduct.[ProductCode]=' " &
Me!
cboProductCode & " ' "
Set rs = db.OpenRecordset(SQL, dbOpenDynaset)
rs.Open
CountRecs = rs.RecordCount
<
This may be obvious, but is the ProductCode field a string type?- Hide quoted text -
- Show quoted text -

The ProductCode is text in a combo box, which I assume is a string.
Should another argument follow dbOpenDynaset because this is an SQL
Server database.

As Mr.Fortune points out you have DA0 not the correct DAO in your
example.
A text box does not mean it's a string field. Do the ProductCodes
contain letters or are they all numeric?
Check the actual data type of the field in the table if you can and
see what it is.

Feb 17 '07 #5

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
by: LJgrnl | last post by:
I've got a type mismatch error that's driving me nutty. Variable blnNoData has the initial value False. If a recordset comes back empty (both .EOF and ..BOF are true) then blnNoData is set to...
7
by: Jack | last post by:
Hi, I am trying to test a sql statement in Access which gives me the error as stated in the heading. The sql statement is built as a part of asp login verification, where the userid and password...
1
by: Sunil Korah | last post by:
I am having some trouble with opening recordsets. I have used code more or less straight from the access help. But still I am getting some errors. I am unable to work out what exactly I am doing...
3
by: Jake | last post by:
I am currently trying to create my own Point Of Sale software for my retail store. I wrote the program with the UPC field as Long integer. When I started to add the products by UPC code, I got a...
3
by: amitbadgi | last post by:
I am getting teh following error while converting an asp application to asp.net, Exception Details: System.Runtime.InteropServices.COMException: Type mismatch. Source Error: Line...
5
by: RICHARD BROMBERG | last post by:
I am using Access 2000 .. I have a table called tblMembers with two fields MemID (Primary key indexed no duplicates) MemName (Thirty character text field) and I have a text box...
19
by: zz12 | last post by:
Hello, is there a setting in IIS 5.0 that would quickly fix the following error?: Microsoft VBScript runtime (0x800A000D) Type mismatch It's strange because some of our .asp pages were...
1
nurikoAnna
by: nurikoAnna | last post by:
I am having troubled debugging with my codes...It always gets an error "TYPE MISMATCH" Below is my code in my frmApplicantsEntry: ...
1
nurikoAnna
by: nurikoAnna | last post by:
I am having troubled debugging with my codes...It always gets an error "TYPE MISMATCH" Below is my code in my frmApplicantsEntry: __________________________________________________...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.