Bill4tektips
Technical User
I have a Form and I would like to check if certain criteria is filled in before it can be closed.
The coding I have put in is:
------------------------------------------------
Private Sub CloseFinding_Click()
On Error GoTo Err_CloseFinding_Click
Dim strUserName As String
strUserName = Environ("UserName")
If ([NCRRD] = "") Then MsgBox "Complete Response Required by Date", vbCritical, "Error Message - '" & strUserName & "'"
Else
If ([ResponseReceived] = "") Then MsgBox "Complete Response Received Date", vbCritical, "Error Message - '" & strUserName & "'"
Else
If ([ActionCompleteDate] = "") Then MsgBox "Complete Action Completed Date", vbCritical, "Error Message - '" & strUserName & "'"
Else
If ([LatestPCD] = "") Then MsgBox "Complete Latest PCD", vbCritical, "Error Message - '" & strUserName & "'"
Else
If ([PCD] = "") Then MsgBox "Complete PCD", vbCritical, "Error Message - '" & strUserName & "'"
Else
If ([RootCauseCode] = "") Then MsgBox "Complete Root Cause Code", vbCritical, "Error Message - '" & strUserName & "'"
Else
If ([Function] = "") Then MsgBox "Complete Function", vbCritical, "Error Message - '" & strUserName & "'"
End If
If ([NCRRD] <> "" And [ResponseReceived] <> "" And [ActionCompleteDate] <> "" And [LatestPCD] <> "" And [PCD] <> "" And [RootCauseCode] <> "" And [Function] <> "") Then
[Status] = "C"
End If
If ([NCRRD] <> "" And [ResponseReceived] <> "" And [ActionCompleteDate] <> "" And [LatestPCD] <> "" And [PCD] <> "" And [RootCauseCode] <> "" And [Function] <> "") Then
MsgBox "Thank you for updating the database!"
End If
Exit_CloseFinding_Click:
Exit Sub
Err_CloseFinding_Click:
MsgBox Err.Description
Resume Exit_CloseFinding_Click
End Sub
-----------------------------------
but when I run it I get an error message "Compile Error Else without If" and the first "Else" is highlighted. Can anyone see what I am doing wrong please?
The coding I have put in is:
------------------------------------------------
Private Sub CloseFinding_Click()
On Error GoTo Err_CloseFinding_Click
Dim strUserName As String
strUserName = Environ("UserName")
If ([NCRRD] = "") Then MsgBox "Complete Response Required by Date", vbCritical, "Error Message - '" & strUserName & "'"
Else
If ([ResponseReceived] = "") Then MsgBox "Complete Response Received Date", vbCritical, "Error Message - '" & strUserName & "'"
Else
If ([ActionCompleteDate] = "") Then MsgBox "Complete Action Completed Date", vbCritical, "Error Message - '" & strUserName & "'"
Else
If ([LatestPCD] = "") Then MsgBox "Complete Latest PCD", vbCritical, "Error Message - '" & strUserName & "'"
Else
If ([PCD] = "") Then MsgBox "Complete PCD", vbCritical, "Error Message - '" & strUserName & "'"
Else
If ([RootCauseCode] = "") Then MsgBox "Complete Root Cause Code", vbCritical, "Error Message - '" & strUserName & "'"
Else
If ([Function] = "") Then MsgBox "Complete Function", vbCritical, "Error Message - '" & strUserName & "'"
End If
If ([NCRRD] <> "" And [ResponseReceived] <> "" And [ActionCompleteDate] <> "" And [LatestPCD] <> "" And [PCD] <> "" And [RootCauseCode] <> "" And [Function] <> "") Then
[Status] = "C"
End If
If ([NCRRD] <> "" And [ResponseReceived] <> "" And [ActionCompleteDate] <> "" And [LatestPCD] <> "" And [PCD] <> "" And [RootCauseCode] <> "" And [Function] <> "") Then
MsgBox "Thank you for updating the database!"
End If
Exit_CloseFinding_Click:
Exit Sub
Err_CloseFinding_Click:
MsgBox Err.Description
Resume Exit_CloseFinding_Click
End Sub
-----------------------------------
but when I run it I get an error message "Compile Error Else without If" and the first "Else" is highlighted. Can anyone see what I am doing wrong please?