Missing END if

Mechele

Registered User.
Local time
Today, 18:48
Joined
Jan 25, 2002
Messages
121
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:confused:
 
Mechele said:
I keep getting an error message:

Block If without 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



I believe your problem lies with the second to last line in this block. You have an "END" listed here. Should this be "End if"?

If it should remain as END, then you are missing one End if statement related to the beginning if-then of this block of code.

HTH
 
If you were to indent your code then you may find it easier to see where your code may be going wrong.

And also, next time you post code to the forum, can you please use the [code] and [/code] tags.

It is so much easier to read: i.e.


Code:
Private Sub NewUser()
    MsgBox "We know you are new...", vbInformation, "New User"
End Sub
 
Code:
DoCmd.DoMenuItem acFormBar, acRecordsMenu, acSaveRecord, , acMenuVer70
is also obsolete...
 

Users who are viewing this thread

Back
Top Bottom