473,406 Members | 2,769 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,406 software developers and data experts.

Datatype mismatch problem...

I hope somebody can help me, I have a problem executing this line of
sql:

Dim rstur As New Recordset
Dim sql As String

sql = "SELECT * FROM tblpat WHERE [pturnumber]='" &
Me![pturnumber] & "'"
Set rstur = CurrentDb.OpenRecordset(sql)

With rstur
If .RecordCount > 0 Then
' Would have some more code in here for duplicating
entry
ElseIf .RecordCount = 0 Then
' Some more code here for adding a new entry to form
End If

End With

I'm trying to create a duplicate set of three fields on a form - only
if the user selects OK on a msg box. This database is for a hospital
system where a patient number may have more than one exam. The
[pturnumber] field is set to be Text in the table and also on the
form. Yet each time I run the code, I get a Data-type mismatch error.
Any suggestions?? It's the smallest, most annoying thing holding the
WHOLE project up!!

Regards,

Sam
Nov 12 '05 #1
1 2941
You don't indicate, but I'm guessing you're using either Access 2000 or
Access 2002.

By default, Access 2000 and Access 2002 use ADO. You're using DAO. From the
fact that the CurrentDb statement doesn't raise an error, you've obviously
added a reference to DAO in your application, but I suspect you didn't
remove the reference to ADO when you did that.

If you have both references, you'll find that you'll need to "disambiguate"
certain declarations, because objects with the same names exist in the 2
models. For example, to ensure that you get a DAO recordset, you'll need to
use Dim rstur as DAO.Recordset (to guarantee an ADO recordset, you'd use Dim
rstur As ADODB.Recordset)

The list of objects with the same names in the 2 models is Connection,
Error, Errors, Field, Fields, Parameter, Parameters, Property, Properties
and Recordset

(And I'd definitely lose the New in the declaration)

--
Doug Steele, Microsoft Access MVP
http://I.Am/DougSteele
(No private e-mails, please)

"Sam Gledhill" <sa***********@hotmail.com> wrote in message
news:a1**************************@posting.google.c om...
I hope somebody can help me, I have a problem executing this line of
sql:

Dim rstur As New Recordset
Dim sql As String

sql = "SELECT * FROM tblpat WHERE [pturnumber]='" &
Me![pturnumber] & "'"
Set rstur = CurrentDb.OpenRecordset(sql)

With rstur
If .RecordCount > 0 Then
' Would have some more code in here for duplicating
entry
ElseIf .RecordCount = 0 Then
' Some more code here for adding a new entry to form
End If

End With

I'm trying to create a duplicate set of three fields on a form - only
if the user selects OK on a msg box. This database is for a hospital
system where a patient number may have more than one exam. The
[pturnumber] field is set to be Text in the table and also on the
form. Yet each time I run the code, I get a Data-type mismatch error.
Any suggestions?? It's the smallest, most annoying thing holding the
WHOLE project up!!

Regards,

Sam

Nov 12 '05 #2

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

Similar topics

2
by: Stephen Briley | last post by:
For some reason, my posts are scrubbed as attachments. Lets hope that sending from the yahoo account works. I'm new to Python and I'm trying to do some database work with MS Access, but I can't...
2
by: Steve Briley | last post by:
I'm new to Python and I'm trying to do some database work with MS Access, but I can't seem to get around a "datatype mismatch error".&nbsp; Here's an example table that I'm working with... ...
4
by: c_bowen | last post by:
I am using Visual Studio .NET 2003 with SQL Server 2000. I am trying to insert the date and time into a SQL database by using hour(now). I am having a hard time trying to figure out which datatype...
1
by: Ken | last post by:
I wrote a function to use in queries that takes a date and adds or subtracts a certain length time and then returns the new value. There are times when my function needs to return Null values. ...
6
by: rn5a | last post by:
I am inserting records in a MS-Access database table. The data type of one of the columns named *OrderDate* in the DB table is Date/Time. This is the SQL query I am using to insert the records in...
2
by: chirag1989 | last post by:
I m havin an error of datatype mismatch actual here i m askin user to input the code in text box and then searchin the record havin that code in database the problem is the code field Bnum is of...
0
by: Snoopy33 | last post by:
I have a query that builds a date from a text field with the date imput as yyyymmdd in the query, so i have to piece it together in my expression as follows: exp:...
9
by: rscheinberg | last post by:
I am working in Access 2007 attempting to grab 2 characters from a text field named ProjectNumber. After determining what 2 digits to add in front to make it a year, I need to do that. I have done...
14
by: rscheinberg | last post by:
I am working in Access 2007 attempting to grab 2 characters from a text field named ProjectNumber. After determining what 2 digits to add in front to make it a year, I need to do that. I have done...
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: 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: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
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...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...

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.