Needing help w/ an 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

Guest

David,
Why not tell us what the error message is and exactly
which line causes it?
Geof.
 
G

Guest

Hello,
..
There really is no error message. I have the code in question
heighlighted with - symbals If I take the If statement out, the rest of the
code works. As it is now nothing happends when I click the command button.

Here is the code again
Thank You for replying

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 I 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
 

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