Error 13: Types don't match ? (1 Viewer)

pookie62

Registered User.
Local time
Today, 01:31
Joined
Jan 16, 2005
Messages
47
Hi,
I got this piece of code but it's giving me error 13 : Types don't match..
Pointer is set to Set rec =

Anyone sees what's wrong with this ?

Code:
Private Sub Kapitaal_AfterUpdate()
    Dim intKap As Currency
    Dim SQL As String
    Dim rec As DAO.Recordset
     
     
    intKap = Me.Kapitaal.Value
     
    SQL = "SELECT Verzekering.v_ID, Verzekering.maatschappij, Verzekering.soort, " _
    & "Verzekering.ProvisiePerc, Polissen.VerzId, " _
    & "([Polissen].[Kapitaal]*[Verzekering].[ProvisiePerc]) AS Prov " _
    & "FROM Verzekering " _
    & "INNER JOIN Polissen ON Verzekering.v_ID = Polissen.VerzId;"
     
    Set rec = CurrentDb.OpenRecordset(SQL, dbOpenSnapshot)
     
    If Not rec.EOF Then
        MsgBox rec!Prov, vbOKCancel, "testing"
    End If
     
    Select Case Me.VerzId
    Case 1
        Me.Provisie = intKap * (rec!ProvisiePerc)
    Case 2:
        Me.Provisie = intKap * (rec!ProvisiePerc)
    Case 4:
        Me.Provisie = intKap * (rec!ProvisiePerc)
    Case Else
        Me.Provisie = 0
    End Select
         
    rec.Close
    Set rec = Nothing
End Sub
 

RuralGuy

AWF VIP
Local time
Yesterday, 17:31
Joined
Jul 2, 2005
Messages
13,825
Are [Polissen].[Kapitaal] and [Verzekering].[ProvisiePerc] number fields that can be multiplied? Are Verzekering.v_ID and Polissen.VerzId both the same type of field?
 

pookie62

Registered User.
Local time
Today, 01:31
Joined
Jan 16, 2005
Messages
47
Hi RuralGuy,
[Polissen].[Kapitaal] = Currency (Euro)
[Verzekering].[ProvisiePerc]= number (double precision)

[Verzekering].[v_ID] = (Auto)number (PK)
[Polissen].[VerzId] = number

ProvisiePerc is supposed to hold a percentage value.
Is the number propertie wrong ?
 

RuralGuy

AWF VIP
Local time
Yesterday, 17:31
Joined
Jul 2, 2005
Messages
13,825
Is [Polissen].[VerzId] a LongInteger? An AutoNumber is a LongInteger.
 

RuralGuy

AWF VIP
Local time
Yesterday, 17:31
Joined
Jul 2, 2005
Messages
13,825
Hmmm...
As a test, remove:
& "([Polissen].[Kapitaal]*[Verzekering].[ProvisiePerc]) AS Prov " _
from the SQL and see if the problem goes away.
 

RuralGuy

AWF VIP
Local time
Yesterday, 17:31
Joined
Jul 2, 2005
Messages
13,825
Have you checked to make sure you don't have any MISSING references?
 

pookie62

Registered User.
Local time
Today, 01:31
Joined
Jan 16, 2005
Messages
47
Hi RuralGuy,
You're the man !
First I removed the line from query, didn't make a difference, then I checked the references while I knew I set the DAO reference.. But I set it to DAO 3.51 and when I changed it to DAO 3.6 the problem was gone..!
Problem solved !

Thanks !!

Got one more question.
Now I have to change the Kapitaal field to let the calculation do it's thing, and fill the value for Me.Provisie.
Is it possible to put in the code that if Field1 OR Field2 OR Field3 are editted the calculation has to run again?
Or would this kill the possibility to manually set a value for Me.Provisie ?
 
Last edited:

RuralGuy

AWF VIP
Local time
Yesterday, 17:31
Joined
Jul 2, 2005
Messages
13,825
I'm sorry but I don't understand what you are asking. Start a new thread with the question and others will see it too.
 

Users who are viewing this thread

Top Bottom