Beste forumgebruikers,
ik heb veel berichten op het internet nagekeken. Nergens kon ik mijn oplossing vinden. Wellicht weet een van jullie experts het hopelijk! Ik heb namelijk een Sendobject code. Als ik op Cancel klik krijg ik de foutmelding Run-time Error 2501 - The sendobject action was cancelled. Wie zou dit stukje code aan willen passen zodat ik geen Foutmelding meer krijg vanuit Access?
Bij voorbaat dank,
Nick Spelthan
ik heb veel berichten op het internet nagekeken. Nergens kon ik mijn oplossing vinden. Wellicht weet een van jullie experts het hopelijk! Ik heb namelijk een Sendobject code. Als ik op Cancel klik krijg ik de foutmelding Run-time Error 2501 - The sendobject action was cancelled. Wie zou dit stukje code aan willen passen zodat ik geen Foutmelding meer krijg vanuit Access?
Private Sub Command4_Click()
'place this code in the clicked event of your command
'button which starts the report, e.g., "Run Report"
' listbox is called List71
' the recordsource for the report is a query
' containing all the field elements you need
Dim strFilter As String
Dim varItem As Variant
Dim Answer As VbMsgBoxResult
' loop through listbox items selected
For Each varItem In Me!List5.ItemsSelected
strFilter = strFilter & "[Bak ID] = '" & _
Me![List5].ItemData(varItem) & "' OR "
Next ' continue loop
'
' the next bit of code will subtract out the last "OR"
If strFilter <> "" Then
strFilter = Left(strFilter, Len(strFilter) - 4)
Else
MsgBox "Er zijn geen bakken geselecteerd."
List5.SetFocus
Exit Sub
End If
'
' now, run the report using strFilter to pass a string
' containing the needed customers
Dim stDocName As String
DoCmd.OpenReport "Sum Reasons", acPreview, , strFilter
DoCmd.SendObject acReport, stDocName
On Error Resume Next
If Err.Number = 2501 Then
MsgBox "Cancelled"
Else
MsgBox Err.Description
End If
On Error GoTo 0
Exit SubEnd Sub
Bij voorbaat dank,
Nick Spelthan