我正在尝试在MS Access中使用编码而不是宏来打开特定报告。我有四份报告,根据我桌子上的值,我们会打开一份特定的报告。麻烦的是我收到了TYPE MISMATCH消息。我尝试使用与Macro Builder中相同的语法,但它不起作用。在下面找到代码。有什么想法吗?非常感谢提前。
Private Sub List201_Click()
On Error GoTo err_list201_click
Dim strDocName1 As String
Dim strDocName2 As String
Dim strDocName3 As String
Dim strDocName4 As String
Dim stLinkCriteria As String
strDocName1 = "brokerClaimsMade1"
strDocName2 = "brokerOccurrence2"
strDocName3 = "nobrokerClaimsMade3"
strDocName4 = "nobrokerOccurrence4"
stLinkCriteria = "[geniusRefNumber] ='" & Me![List201] & "'"
If "[brokerInvolved] = 1" And [wording] <> 2 Then
DoCmd.OpenReport strDocName1, acViewPreview, , stLinkCriteria, acDialog
ElseIf [brokerInvolved] = 1 And [wording] = 2 Then
DoCmd.OpenReport strDocName2, acViewPreview, , stLinkCriteria, acDialog
ElseIf [brokerInvolved] = 2 And [wording] = 2 Then
DoCmd.OpenReport strDocName3, acViewPreview, , stLinkCriteria, acDialog
ElseIf [brokerInvolved] = 2 And [wording] <> 2 Then
DoCmd.OpenReport strDocName4, acViewPreview, , stLinkCriteria, acDialog
End If
exit_list201_click:
Exit Sub
err_list201_click:
MsgBox Err.Description
Resume exit_list201_click
End Sub
答案 0 :(得分:1)
If "[brokerInvolved] = 1" And [wording] <> 2 Then
删除双引号 - 您正在对字符串和布尔表达式进行逻辑AND。
If [brokerInvolved] = 1 And [wording] <> 2 Then