Private Sub Button160_Click()
Function Aspiranti()
On Error GoTo Aspiranti_Err
With CodeContextObject
If (.F27 <> "") Then
TempVars.Add "Perem27", .F27
Else
TempVars.Add "Perem27", "*"
If (.F28 <> "") Then
TempVars.Add "Perem28", .F28
Else
TempVars.Add "Perem28", "*"
If (.F29 <> "") Then
TempVars.Add "Perem29", .F29
Else
TempVars.Add "Perem29", "*"
End If
DoCmd.SetFilter "", "[N ruk] Like [TempVars]![Perem27] And [Spec VAK] Like [TempVars]![Perem28] And Year([Date]) Like [TempVars]![Perem29]", ""
If (Forms!Asperant.CurrentRecord = 1 And Forms!Asperant.NewRecord = -1) Then
Beep
MsgBox "Ne naideno!", vbOKOnly, "Vnimanie!"
DoCmd.ShowAllRecords
End If
End With
Aspiranti_Exit:
Exit Function
Aspiranti_Err:
MsgBox Error$
Resume Aspiranti_Exit
End Function
End Sub
答案 0 :(得分:0)
你似乎错过了两个&#34; End If&#34;
With CodeContextObject
If (.F27 <> "") Then
TempVars.Add "Perem27", .F27
Else
TempVars.Add "Perem27", "*"
End If ' <<<== missing ?
If (.F28 <> "") Then
TempVars.Add "Perem28", .F28
Else
TempVars.Add "Perem28", "*"
End If ' <<<== missing ?
If (.F29 <> "") Then
TempVars.Add "Perem29", .F29
Else
TempVars.Add "Perem29", "*"
End If
DoCmd.SetFilter "", "[N ruk] Like [TempVars]![Perem27] And [Spec VAK] Like [TempVars]![Perem28] And Year([Date]) Like [TempVars]![Perem29]", ""
If (Forms!Asperant.CurrentRecord = 1 And Forms!Asperant.NewRecord = -1) Then
Beep
MsgBox "Ne naideno!", vbOKOnly, "Vnimanie!"
DoCmd.ShowAllRecords
End If
End With
答案 1 :(得分:0)
Function
嵌套在Sub
内。你不能在VBA中这样做。如果这应该是你的Button的点击处理程序,删除行
Function Aspiranti()
和
End Function
如果没有,请删除
行Private Sub Button160_Click()
和
End Sub