0

我有一个 SQL 数据库,其中列出了邮件必须满足的条件。

对于我收到的每封邮件都在数据库中进行搜索,如果满足其中一条记录的条件,则应为该邮件调用另一个 Sub。要执行哪个 Sub 也在数据库中定义。

一切正常,但我无法调用 Sub。

Sub automatik_sql() 
'VERWEIS auf ActiveX Data Objects 6.1 Library notwendig'
Dim olApp As Outlook.Application
Dim olitem As Outlook.MailItem
Set olApp = Outlook.Application
Set olitem = Application.ActiveInspector.CurrentItem

Dim con As ADODB.connection
Dim rec As ADODB.recordset
Dim MySQL As String
Dim ausloeser As Boolean
ausloeser = True
MySQL = "SELECT MA_Index, beding_body, beding_subj, aktion FROM Mail_Automatik where (empfaenger = '" & olitem.To & "' and absender ='" & olitem.SenderEmailAddress & "')"
Set con = New ADODB.connection
con.Open "Provider=sqloledb; Data Source=meinedaten; Initial Catalog=STAMMDATEN; INTEGRATED SECURITY=sspi;"
Set rec = con.Execute(MySQL)
While Not rec.EOF
If Not IsNull(rec.Fields("beding_body").Value) Then
  If InStr(olitem.Body, rec.Fields("beding_body").Value) = 0 Then ausloeser = False
End If
If Not IsNull(rec.Fields("beding_subj").Value) Then
    If InStr(olitem.Subject, rec.Fields("beding_subj").Value) = 0 Then ausloeser = False
End If

现在我有问题:

If ausloeser = True Then Call rec.Fields("aktion")
rec.movenext
Wend
End Sub

当我在一台德语机器上工作时,我只有德语的错误(在 Sub 的开头弹出):

Fehler beim kompilieren: Unzulässige Verwendung einer Eigenschaft 翻译:“编译失败:非法使用财产”

有人知道吗?

4

1 回答 1

0

If ausloeser = True Then Call rec.Fields(aktion)

RecordSet.Fields is a property -- a collection of fields in the recordset. It's not a method, so it can't be called as it's being used here.

I suspect that the intent is to call some other method, and pass it the content of the aktion field? If so the syntax would be Then Call othermethod(rec.Fields("aktion"))

于 2013-09-09T11:42:18.590 回答