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