Needing help with IF statement

G

Guest

Hello, I'm having some trouble with my code below. One of my If statements
causes the code not to work. If I take the If Statement out it runs fine. I
highlighted the area that I'm having problems with.

If any one could help me with this, I thank you

Private Sub SaveCmd_Click()
Dim cancel As Integer
Dim stdocname As String
Dim stLinkCriteria As String
Dim chk As Object
Dim OneSelected As Boolean

If (DLookup("ReqStudentIDOpt", "DbOptionsTbl")) = True Then

If IsNull(StudentID) Then
MsgBox "Please Enter Your Student ID.", vbOKOnly +_ vbExclamation
StudentID.SetFocus
cancel = -1


ElseIf IsNull(Fname) Then
MsgBox "Please Enter Your First Name.", vbOKOnly +_ vbExclamation
Fname.SetFocus
cancel = -1
ElseIf IsNull(Lname) Then
MsgBox "Please Enter Your Last Name.", vbOKOnly +_ vbExclamation
Lname.SetFocus
cancel = -1
ElseIf IsNull(TOT) Then
MsgBox "Please a Type of Test", vbOKOnly + vbExclamation
TOT.SetFocus
cancel = -1
----------------------------------------------------------
'This is the part that is giving me problems
ElseIf (TOT.Column(0)) = "Clep Test" Then
If IsNull(ClepName) Then
MsgBox "Please a CLEP Test", vbOKOnly + vbExclamation
ClepName.SetFocus
cancel = -1
------------------------------------------------------
Else

If Not (TOT.Column(0)) = "Placement Test" Then
DoCmd.Close

stdocname = "ThankYouFrm"
DoCmd.OpenForm stdocname, , , stLinkCriteria
Else
If (TOT.Column(0)) = "Placement Test" Then
OneSelected = False


For Each chk In Controls

If chk.ControlType = acOptionButton Then

If chk.Value = True Then

OneSelected = True



Exit For
End If
End If

Next


If OneSelected Then
DoCmd.Close

stdocname = "ThankYouFrm"
DoCmd.OpenForm stdocname, , , stLinkCriteria
Else

MsgBox "You must select at least one of the tests"
End If

End If
End If

End If
End If

End If
End Sub
 
G

Graham Mandeno

Hi David

It seems your line:
If IsNull(ClepName) Then
has no matching End If.

Well, it does have one, but it's in the wrong place - at the end of the
procedure.

Move one of your End If lines from the end to just after:
MsgBox "Please a CLEP Test", vbOKOnly + vbExclamation
ClepName.SetFocus
cancel = -1

I can't guarantee this is the only problem with your logic here. It would
help a lot if you were to indent your code consistently.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Similar Threads


Top