出于某种原因,我无法使dlookup正常运行,我不断收到错误。此错误是数据类型不匹配。
Option Compare Database
Private Sub Command131_Click()
DoCmd.SetWarnings False
If (Nz(DLookup("LetterSent1Bool", "dbo_T_Volunteers", _
"VolunteerID = '" & Me![VolunteerID] & "'"))) > 0 Then
MsgBox "ERROR ! This Volunteer has already received this Letter ,"
Else
DoCmd.OpenQuery "ProduceLettersSixToTwelve", , acReadOnly
If DCount("*", "dbo_T_SixToTwelveWeeks") > 0 Then
MsgBox "SUCCESS ! Please Open The Mail Merge Template"
Else
MsgBox "ERROR ! No Records Found"
End If
End If
End Sub
答案 0 :(得分:1)
想出来,我需要删除&周围的引号我![VolunteerID]
Option Compare Database
Private Sub Command131_Click()
DoCmd.SetWarnings False
If (Nz(DLookup("LetterSent1Bool", "dbo_T_Volunteers", _
"VolunteerID = " & Me![VolunteerID]))) > 0 Then
MsgBox "ERROR ! This Volunteer has already received this Letter ,"
Else
DoCmd.OpenQuery "ProduceLettersSixToTwelve", , acReadOnly
If DCount("*", "dbo_T_SixToTwelveWeeks") > 0 Then
MsgBox "SUCCESS ! Please Open The Mail Merge Template"
Else
MsgBox "ERROR ! No Records Found"
End If
End If
End Sub