By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
424,495 Members | 1,146 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 424,495 IT Pros & Developers. It's quick & easy.

Datatype mismatch problem...

P: n/a
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
Share this Question
Share on Google+
1 Reply


P: n/a
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 discussion thread is closed

Replies have been disabled for this discussion.