R
Ronald
Hi all.
This code:
Private Sub cboNamen_AfterUpdate()
Dim intRowCount As Integer
Dim dblLicenceFee As Double
Dim intSelectCount As Integer
dblLicenceFee = 0#
intSelectCount = 0
For intRowCount = 0 To Me![cboNamen].Recordset.RecordCount - 1
If (Me![cboNamen].Selected(intRowCount) = True) Then
dblLicenceFee = dblLicenceFee + CDbl(Me![cboNamen].Column(2,
intRowCount))
intSelectCount = intSelectCount + 1
End If
Next intRowCount
If (intSelectCount = 0) Then
MsgBox "No licence selected!", vbInformation
Else
Me![txtAvgLicence] = dblLicenceFee / intSelectCount
End If
End Sub
I put in the event you can see of a multi selectable combobox (Access 2007).
The code is OK, all records are filled, but in certain specific
circumstances (I know exactly when) I get an ‘Invalid use of Null’ error in
the line that adds the LicenceFee. But when I go to error correction and
press F5, the code continues and completes without any error.
I tried requerying the control, build in a loop (in case of a timing issue),
using other events, but I cannot get it fixed.
I feel it might be a bug in Access. I have created a specific database to
check the behavior. How can I get it to someone to confirm the behavior and
maybe get it to Microsoft?
Thanks,
Ronald.
This code:
Private Sub cboNamen_AfterUpdate()
Dim intRowCount As Integer
Dim dblLicenceFee As Double
Dim intSelectCount As Integer
dblLicenceFee = 0#
intSelectCount = 0
For intRowCount = 0 To Me![cboNamen].Recordset.RecordCount - 1
If (Me![cboNamen].Selected(intRowCount) = True) Then
dblLicenceFee = dblLicenceFee + CDbl(Me![cboNamen].Column(2,
intRowCount))
intSelectCount = intSelectCount + 1
End If
Next intRowCount
If (intSelectCount = 0) Then
MsgBox "No licence selected!", vbInformation
Else
Me![txtAvgLicence] = dblLicenceFee / intSelectCount
End If
End Sub
I put in the event you can see of a multi selectable combobox (Access 2007).
The code is OK, all records are filled, but in certain specific
circumstances (I know exactly when) I get an ‘Invalid use of Null’ error in
the line that adds the LicenceFee. But when I go to error correction and
press F5, the code continues and completes without any error.
I tried requerying the control, build in a loop (in case of a timing issue),
using other events, but I cannot get it fixed.
I feel it might be a bug in Access. I have created a specific database to
check the behavior. How can I get it to someone to confirm the behavior and
maybe get it to Microsoft?
Thanks,
Ronald.