Type mismatch error

D

Daniel W. Muill

I get a run-time error: 13 - Type Mistmatch error in the
following code:


Private Sub Taxable_Exit(Cancel As Integer)

Dim db As Database
Dim rs As Recordset
Dim ReceiptNum As Long
Dim TempReceipt As String

Set db = CurrentDb
Set rs = db.OpenRecordset("ReceiptNumber",
DB_OPEN_DYNASET)

If IsNull(DonorReceiptNumber) Then
GoTo AA
Else
GoTo ZZ
End If
AA:
If Taxable = "Y" Then
rs.MoveFirst
'rs.Edit
ReceiptNum = Val(rs![TaxableReceiptNumber])
TempReceipt = "R " + Mid(rs![TaxableReceiptNumber],
2, 6)
ReceiptNum = ReceiptNum + 1
rs![TaxableReceiptNumber] = Str(ReceiptNum)
rs.Update
GoTo BB
Else
rs.MoveFirst
'rs.Edit
ReceiptNum = Val(rs![NonTaxableReceiptNumber])
TempReceipt = "N " + Mid(rs![TaxableReceiptNumber],
2, 6)
ReceiptNum = ReceiptNum + 1
rs![NonTaxableReceiptNumber] = Str(ReceiptNum)
rs.Update
GoTo BB
End If


BB:

ZZ:
End Sub

The error comes on the Set rs= line

This code was copied from an older application copied
from Access 97. I think this problem has something to do
with references but I have checked my references and they
are as follows:

Visual Basic for Applications
Microsoft Access 10.0 Object Library
OLE Automation
Microsoft ActiveX Data objects 2.1 Library
Microsoft DAO 3.6 Object Library

I believe I need an additional reference but I am not
sure which one.
 
D

Daniel W. Muill

That did it. Thank you. Any idea why the change?
-----Original Message-----
Dim rs as DAO.Recordset
-----Original Message-----
I get a run-time error: 13 - Type Mistmatch error in the
following code:


Private Sub Taxable_Exit(Cancel As Integer)

Dim db As Database
Dim rs As Recordset
Dim ReceiptNum As Long
Dim TempReceipt As String

Set db = CurrentDb
Set rs = db.OpenRecordset("ReceiptNumber",
DB_OPEN_DYNASET)

If IsNull(DonorReceiptNumber) Then
GoTo AA
Else
GoTo ZZ
End If
AA:
If Taxable = "Y" Then
rs.MoveFirst
'rs.Edit
ReceiptNum = Val(rs![TaxableReceiptNumber])
TempReceipt = "R " + Mid(rs![TaxableReceiptNumber],
2, 6)
ReceiptNum = ReceiptNum + 1
rs![TaxableReceiptNumber] = Str(ReceiptNum)
rs.Update
GoTo BB
Else
rs.MoveFirst
'rs.Edit
ReceiptNum = Val(rs![NonTaxableReceiptNumber])
TempReceipt = "N " + Mid(rs![TaxableReceiptNumber],
2, 6)
ReceiptNum = ReceiptNum + 1
rs![NonTaxableReceiptNumber] = Str(ReceiptNum)
rs.Update
GoTo BB
End If


BB:

ZZ:
End Sub

The error comes on the Set rs= line

This code was copied from an older application copied
from Access 97. I think this problem has something to do
with references but I have checked my references and they
are as follows:

Visual Basic for Applications
Microsoft Access 10.0 Object Library
OLE Automation
Microsoft ActiveX Data objects 2.1 Library
Microsoft DAO 3.6 Object Library

I believe I need an additional reference but I am not
sure which one.

.
.
 
A

Alex Ivanov

You might also move the reference to DAO somewhere above ADO in the refs
list, but I agree with Daniel, an explicit declaration is better.

Alex.

Daniel W. Muill said:
That did it. Thank you. Any idea why the change?
-----Original Message-----
Dim rs as DAO.Recordset
-----Original Message-----
I get a run-time error: 13 - Type Mistmatch error in the
following code:


Private Sub Taxable_Exit(Cancel As Integer)

Dim db As Database
Dim rs As Recordset
Dim ReceiptNum As Long
Dim TempReceipt As String

Set db = CurrentDb
Set rs = db.OpenRecordset("ReceiptNumber",
DB_OPEN_DYNASET)

If IsNull(DonorReceiptNumber) Then
GoTo AA
Else
GoTo ZZ
End If
AA:
If Taxable = "Y" Then
rs.MoveFirst
'rs.Edit
ReceiptNum = Val(rs![TaxableReceiptNumber])
TempReceipt = "R " + Mid(rs![TaxableReceiptNumber],
2, 6)
ReceiptNum = ReceiptNum + 1
rs![TaxableReceiptNumber] = Str(ReceiptNum)
rs.Update
GoTo BB
Else
rs.MoveFirst
'rs.Edit
ReceiptNum = Val(rs![NonTaxableReceiptNumber])
TempReceipt = "N " + Mid(rs![TaxableReceiptNumber],
2, 6)
ReceiptNum = ReceiptNum + 1
rs![NonTaxableReceiptNumber] = Str(ReceiptNum)
rs.Update
GoTo BB
End If


BB:

ZZ:
End Sub

The error comes on the Set rs= line

This code was copied from an older application copied
from Access 97. I think this problem has something to do
with references but I have checked my references and they
are as follows:

Visual Basic for Applications
Microsoft Access 10.0 Object Library
OLE Automation
Microsoft ActiveX Data objects 2.1 Library
Microsoft DAO 3.6 Object Library

I believe I need an additional reference but I am not
sure which one.

.
.
 
D

Douglas J. Steele

It's because the ADO and DAO models both have a recordset object in them.
You've got the ADO library (Microsoft ActiveX Data objects 2.1 Library)
higher in your list of references than the DAO library (Microsoft DAO 3.6
Object Library). If you don't disambiguate, Access chooses the first one it
comes to. If you're not using ADO in your application, you should get rid of
the reference to it.

The list of objects with the same names in the 2 models is Connection,
Error, Errors, Field, Fields, Parameter, Parameters, Property, Properties
and Recordset. If you don't remove the ADO reference, you should check your
code for any declarations to any of those objects and fix them.


--
Doug Steele, Microsoft Access MVP

(No private e-mails, please)



Daniel W. Muill said:
That did it. Thank you. Any idea why the change?
-----Original Message-----
Dim rs as DAO.Recordset
-----Original Message-----
I get a run-time error: 13 - Type Mistmatch error in the
following code:


Private Sub Taxable_Exit(Cancel As Integer)

Dim db As Database
Dim rs As Recordset
Dim ReceiptNum As Long
Dim TempReceipt As String

Set db = CurrentDb
Set rs = db.OpenRecordset("ReceiptNumber",
DB_OPEN_DYNASET)

If IsNull(DonorReceiptNumber) Then
GoTo AA
Else
GoTo ZZ
End If
AA:
If Taxable = "Y" Then
rs.MoveFirst
'rs.Edit
ReceiptNum = Val(rs![TaxableReceiptNumber])
TempReceipt = "R " + Mid(rs![TaxableReceiptNumber],
2, 6)
ReceiptNum = ReceiptNum + 1
rs![TaxableReceiptNumber] = Str(ReceiptNum)
rs.Update
GoTo BB
Else
rs.MoveFirst
'rs.Edit
ReceiptNum = Val(rs![NonTaxableReceiptNumber])
TempReceipt = "N " + Mid(rs![TaxableReceiptNumber],
2, 6)
ReceiptNum = ReceiptNum + 1
rs![NonTaxableReceiptNumber] = Str(ReceiptNum)
rs.Update
GoTo BB
End If


BB:

ZZ:
End Sub

The error comes on the Set rs= line

This code was copied from an older application copied
from Access 97. I think this problem has something to do
with references but I have checked my references and they
are as follows:

Visual Basic for Applications
Microsoft Access 10.0 Object Library
OLE Automation
Microsoft ActiveX Data objects 2.1 Library
Microsoft DAO 3.6 Object Library

I believe I need an additional reference but I am not
sure which one.

.
.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top