G
Guest
I am getting an error (2105) in the following code:
Private Sub Form_BeforeUpdate(Cancel As Integer)
Dim strList As String
Dim intLen As Integer
Dim strSelectedRecord As Variant
Dim strOSUser As String
strList = ""
If Recruitment.Value = True And Me.lstProviderType.ItemsSelected.Count =
0 Then
MsgBox "Please select a provider type." _
, vbExclamation + vbOKOnly, "PROVIDER TYPE"
lstProviderType.SetFocus
Exit Sub
ElseIf Recruitment.Value = True And
Me.lstProviderType.ItemsSelected.Count > 0 Then
For Each strSelectedRecord In lstProviderType.ItemsSelected
strList = strList + lstProviderType.Column(1, strSelectedRecord)
& ","
Next strSelectedRecord
intLen = Len(strList)
[Provider Type] = Left(strList, intLen - 1)
End If
strOSUser = modPR_Stats.fOSUserName
[Modified By].Value = strOSUser
[Modified Date].Value = Now()
End Sub
I checked the MS knowledge db and here is what it says:
CAUSE
Microsoft Access cannot perform the specified command because the
BeforeUpdate event procedure is still running. This is true even if the
Cancel parameter is set to True or if a CancelEvent macro attempts to cancel
the action.
RESOLUTION
Instead of setting the Cancel parameter to True, or using the CancelEvent
action, use a SendKeys statement if that is an option with the command you
are trying to use. The SendKeys statement sends keystrokes to the Microsoft
Access buffer, where they wait until the BeforeUpdate event procedure is
finished.
I'm thinking there is better solution to the problem. Any ideas are
appreciated. Thanks in advance.
Private Sub Form_BeforeUpdate(Cancel As Integer)
Dim strList As String
Dim intLen As Integer
Dim strSelectedRecord As Variant
Dim strOSUser As String
strList = ""
If Recruitment.Value = True And Me.lstProviderType.ItemsSelected.Count =
0 Then
MsgBox "Please select a provider type." _
, vbExclamation + vbOKOnly, "PROVIDER TYPE"
lstProviderType.SetFocus
Exit Sub
ElseIf Recruitment.Value = True And
Me.lstProviderType.ItemsSelected.Count > 0 Then
For Each strSelectedRecord In lstProviderType.ItemsSelected
strList = strList + lstProviderType.Column(1, strSelectedRecord)
& ","
Next strSelectedRecord
intLen = Len(strList)
[Provider Type] = Left(strList, intLen - 1)
End If
strOSUser = modPR_Stats.fOSUserName
[Modified By].Value = strOSUser
[Modified Date].Value = Now()
End Sub
I checked the MS knowledge db and here is what it says:
CAUSE
Microsoft Access cannot perform the specified command because the
BeforeUpdate event procedure is still running. This is true even if the
Cancel parameter is set to True or if a CancelEvent macro attempts to cancel
the action.
RESOLUTION
Instead of setting the Cancel parameter to True, or using the CancelEvent
action, use a SendKeys statement if that is an option with the command you
are trying to use. The SendKeys statement sends keystrokes to the Microsoft
Access buffer, where they wait until the BeforeUpdate event procedure is
finished.
I'm thinking there is better solution to the problem. Any ideas are
appreciated. Thanks in advance.