I keep getting an error message:
Block If without end if
I've checked the following code several times and I can't seem to find where I'm missing an end if statement.
Can someone look at the code below and tell me where the end if statement is missing? Is it possible I have too many end if statements?
Private Sub Command79_Click()
Me.Status = InputBox("Are you adding your spouse to your dental coverage? If so, type in the word Add. If instead you just want to made changes to information listed, type in the word Change.")
If IsNull(Me.Status) Then
Cancel = yes
Me.Undo
DoCmd.GoToControl "DependentFirstName"
End If
If Me.Status = "Add" Then
If Me.TempDep1 = 3 Then
Me.Answer = MsgBox("Is the information you entered correct?", vbYesNo)
If Me.Answer = 6 Then
DoCmd.DoMenuItem acFormBar, acRecordsMenu, acSaveRecord, , acMenuVer70
DoCmd.Close acForm, "DependentFormDentalSpouse"
DoCmd.OpenForm "DependentFormDentalSpouse"
End If
If Me.Answer = 7 Then
Cancel = yes
Me.Undo
DoCmd.GoToControl "DependentFirstName"
End If
If IsNull(Me.Answer) Then
Cancel = yes
DoCmd.GoToControl "DependentFirnstName"
End
End If
If Me.TempDep1 = 1 Then
Me.TempCoverage = "Dental Insurance"
Me.Answer = MsgBox("Is the information you entered correct?", vbYesNo)
If Me.Answer = 6 Then
Dim rs1 As Recordset
Set rs1 = CurrentDb.OpenRecordset("DependentTable")
With rs1
.AddNew
.Fields("FC") = "A"
.Fields("Employee") = Forms!loginform!Employee
.Fields("Company") = "1234"
.Fields("Dependent") = 0
.Fields("PlanType") = "DN"
.Fields("PlanCode") = "DEN"
.Fields("DependentSSN") = Me.DependentSSN
.Fields("DependentFirstName") = Me.DependentFirstName
.Fields("DependentLastName") = Me.DependentLastName
.Fields("DependentDOB") = Me.DependentDOB
.Fields("DependentGender") = Me.Combo21
.Fields("DependentRelationship") = Me.DependentRelationship
.Fields("StartDate") = #1/1/2004#
.Fields("StopDate") = #12/31/2004#
.Fields("CreationDate") = Date
.Fields("TimeStamp") = Time
.Fields("EmpStart") = #1/1/2004#
.Fields("UpdDate") = Date
.Update
.Close
End With
DoCmd.Close acForm, "DependentFormDentalSpouse"
DoCmd.OpenForm "DependentFormDentalSpouse"
End If
If Me.Answer = 7 Then
Cancel = yes
Me.Undo
DoCmd.GoToControl "DependentFirstName"
End If
If IsNull(Me.Answer) Then
Cancel = yes
Me.Undo
DoCmd.GoToControl "DependentFirstName"
End If
End If
End If
If Me.Status = "Change" Then
Me.Answer = MsgBox("Is the information you entered correct?", vbYesNo)
If Me.Answer = 6 Then
DoCmd.DoMenuItem acFormBar, acRecordsMenu, acSaveRecord, , acMenuVer70
DoCmd.Close acForm, "DependentFormDentalSpouse"
DoCmd.OpenForm "DependentFormDentalSpouse"
End If
If Me.Answer = 7 Then
Cancel = yes
Me.Undo
DoCmd.GoToControl "DependentFirstName"
End If
If IsNull(Me.Answer) Then
Cancel = yes
DoCmd.GoToControl "DependentFirstName"
End If
End If
End Sub
Block If without end if
I've checked the following code several times and I can't seem to find where I'm missing an end if statement.
Can someone look at the code below and tell me where the end if statement is missing? Is it possible I have too many end if statements?
Private Sub Command79_Click()
Me.Status = InputBox("Are you adding your spouse to your dental coverage? If so, type in the word Add. If instead you just want to made changes to information listed, type in the word Change.")
If IsNull(Me.Status) Then
Cancel = yes
Me.Undo
DoCmd.GoToControl "DependentFirstName"
End If
If Me.Status = "Add" Then
If Me.TempDep1 = 3 Then
Me.Answer = MsgBox("Is the information you entered correct?", vbYesNo)
If Me.Answer = 6 Then
DoCmd.DoMenuItem acFormBar, acRecordsMenu, acSaveRecord, , acMenuVer70
DoCmd.Close acForm, "DependentFormDentalSpouse"
DoCmd.OpenForm "DependentFormDentalSpouse"
End If
If Me.Answer = 7 Then
Cancel = yes
Me.Undo
DoCmd.GoToControl "DependentFirstName"
End If
If IsNull(Me.Answer) Then
Cancel = yes
DoCmd.GoToControl "DependentFirnstName"
End
End If
If Me.TempDep1 = 1 Then
Me.TempCoverage = "Dental Insurance"
Me.Answer = MsgBox("Is the information you entered correct?", vbYesNo)
If Me.Answer = 6 Then
Dim rs1 As Recordset
Set rs1 = CurrentDb.OpenRecordset("DependentTable")
With rs1
.AddNew
.Fields("FC") = "A"
.Fields("Employee") = Forms!loginform!Employee
.Fields("Company") = "1234"
.Fields("Dependent") = 0
.Fields("PlanType") = "DN"
.Fields("PlanCode") = "DEN"
.Fields("DependentSSN") = Me.DependentSSN
.Fields("DependentFirstName") = Me.DependentFirstName
.Fields("DependentLastName") = Me.DependentLastName
.Fields("DependentDOB") = Me.DependentDOB
.Fields("DependentGender") = Me.Combo21
.Fields("DependentRelationship") = Me.DependentRelationship
.Fields("StartDate") = #1/1/2004#
.Fields("StopDate") = #12/31/2004#
.Fields("CreationDate") = Date
.Fields("TimeStamp") = Time
.Fields("EmpStart") = #1/1/2004#
.Fields("UpdDate") = Date
.Update
.Close
End With
DoCmd.Close acForm, "DependentFormDentalSpouse"
DoCmd.OpenForm "DependentFormDentalSpouse"
End If
If Me.Answer = 7 Then
Cancel = yes
Me.Undo
DoCmd.GoToControl "DependentFirstName"
End If
If IsNull(Me.Answer) Then
Cancel = yes
Me.Undo
DoCmd.GoToControl "DependentFirstName"
End If
End If
End If
If Me.Status = "Change" Then
Me.Answer = MsgBox("Is the information you entered correct?", vbYesNo)
If Me.Answer = 6 Then
DoCmd.DoMenuItem acFormBar, acRecordsMenu, acSaveRecord, , acMenuVer70
DoCmd.Close acForm, "DependentFormDentalSpouse"
DoCmd.OpenForm "DependentFormDentalSpouse"
End If
If Me.Answer = 7 Then
Cancel = yes
Me.Undo
DoCmd.GoToControl "DependentFirstName"
End If
If IsNull(Me.Answer) Then
Cancel = yes
DoCmd.GoToControl "DependentFirstName"
End If
End If
End Sub