【发布时间】:2020-09-13 05:57:54
【问题描述】:
我们正在尝试构建一个 Access 应用程序。首先,它将更新数据条目,然后生成 Outlook 应用程序。 它会更新数据,但会因为 Outlook 而崩溃(这就是我们的想法)。
我们尝试过的:
- 早绑定/晚绑定
- DoEvents
- 调试找出在哪一步会崩溃,但在调试模式下不会崩溃
- DoCmd.SendObject
我们的代码:
Private Sub cmd_Freigegeben_Click()
Dim OutApp As Outlook.Application
Dim OutMail As Outlook.MailItem
Dim strbody As String
Dim sname As String
Dim sTo As String
Dim sSAP As String
Dim sFRE As String
Dim sFile As String
Dim iClick As String
sTo = Me.txt_EMail.Value
sSAP = Me.txt_SAP.Value
sFRE = Me.txt_FreigabeID
Dim FlName As String
sFile = Me.txt_Link
sFile = Replace(sFile, "\\file01\", "W:\")
FlName = sFile
If FlName = "" Then
MsgBox "Bitte wähle einen Datensatz aus!", vbOKOnly, "Vorsicht"
Exit Sub
End If
iClick = MsgBox( _
prompt:="Die Änderung dieses Datensatzes mit der SAP-Nummer: (" & sSAP & ") und mit der Freigabe-ID: (" & sFRE & ") wird gestartet, möchtest du fortfahren?", _
Buttons:=vbYesNo, Title:="FREIGEGEBEN")
If iClick = vbYes Then
GoTo UPDATE
ElseIf iClick = vbNo Then
Exit Sub
End If
UPDATE:
Call mod_update.freigegeben_update
On Error GoTo Fehler
Set OutApp = New Outlook.Application
Set OutMail = OutApp.CreateItem(olMailItem)
strbody = "Hallo," & vbNewLine & vbNewLine & "ich habe dir folgende Wohnung mit der SAP-Nummer freigegeben: " & sSAP & vbNewLine & vbNewLine & "LG :)"
With OutMail
.To = sTo
.Subject = Me.cbo_Freigabeliste.Value & " Freigabe - " & sSAP & " , Freigabe-ID: " & sFRE
.Body = strbody
.display
End With
Set OutMail = Nothing
Set OutApp = Nothing
Call Felder_Leeren
Fehler:
If Err.Number <> 0 And Err.Number <> 40040 Then MsgBox "OMG! Da ist was falsch! Bitte melden!" & vbCrLf & "Fehler: " & Err.Number, vbCritical, "Computer sagt nein :("
End Sub
也许有人遇到过这种情况并且知道该怎么做? (我们花了 2 天时间寻找解决方案)
谢谢!
【问题讨论】:
-
将日志消息写入文本文件以找出崩溃的确切位置。
-
mod_update.freigegeben_update 是什么?
-
谢谢@Andre,现在我们发现它在另一个步骤中崩溃了
-
感谢@ThomasG,我们发现错误在于将记录集绑定到列表框导致崩溃...但我们可能有解决方案:)