-
[vba]
Private Sub Kapitaal_AfterUpdate()
Dim strProvisie As Variant
Dim Prov As Variant
Dim strKap As Variant
Dim SQL As String
Dim rec As DAO.Recordset
strKap = 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
' ***************************************
' Where is the value for strProvPerc set?
' ***************************************
Me.Provisie = strKap * strProvPerc
Case 2: 'Me.Provisie = Me.Kapitaal * (rec!Prov)
Case 4: 'Me.Provisie = Me.Kapitaal * (rec!Prov)
Case Else
Me.Provisie = 0
' ***************************************
' Where is the value for strProv set?
' ***************************************
MsgBox stProv, vbOKCancel, "Provisie Berekening"
End If
rec.Close
Set rec = Nothing
End Sub
[/vba]
A couple of things here:
- Make sure you have Option Explicit set at the top of your module. There are some variables here that don't appear to be dimensioned, which is going to cause you problems.
- Is there are reason that you have set a number of variables as Variant? You should only use variant if there's a possibility that the value will be Null, otherwise avoid them, and use a variable type that reflects the data that will be stored. Also, the name of your variable should reflect the data type, so "strKap" would indicate a string variable, "varKap" indicates variant.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules