fraser_lindsay
Access wannabe
- Local time
- Today, 09:48
- Joined
- Sep 7, 2005
- Messages
- 218
Help!
I have some code which runs in the after update of an unbound text box. The user enters a number of questions required which is compared to the total number on the record set, also from a unbound combo on the form.
The code works (kind of) but for some reason the 'IF' part isn't working and I can't see why.
I want the latter part of the code to trigger only if the users requests more questions than there is in the database, but it triggers no matter what they type in, even if it is less than the total number. Why?
I have some code which runs in the after update of an unbound text box. The user enters a number of questions required which is compared to the total number on the record set, also from a unbound combo on the form.
The code works (kind of) but for some reason the 'IF' part isn't working and I can't see why.
I want the latter part of the code to trigger only if the users requests more questions than there is in the database, but it triggers no matter what they type in, even if it is less than the total number. Why?
Code:
If Me.txtMCQnumber.Value < Me.txtTotalMCQ.Value Then
'do nothing
Else
On Error GoTo txtMCQnumber_AfterUpdate_Err
Dim intAnswer As Integer
Dim strSQL As String
intAnswer = MsgBox("There are only " & Me.txtTotalMCQ.Value & _
" multiple choice questions in the database." & vbCrLf & _
"Would you like to view all questions?" _
, vbQuestion + vbYesNo, "Industrial Hygiene Exam Database")
If intAnswer = vbYes Then
Me.txtMCQnumber.Value = ""
Me.cmdMCQExam.SetFocus
Me.txtMCQnumber.Enabled = False
Me.chkAllQuestions.Value = -1
DoCmd.SetWarnings False
DoCmd.SetWarnings True
MsgBox "All questions have been selected." _
, vbInformation, "Industrial Hygiene Exam Database"
Response = acDataErrAdded
Else
MsgBox "Please choose smaller number of questions." _
, vbInformation, "Industrial Hygiene Exam Database"
Response = acDataErrContinue
End If
txtMCQnumber_AfterUpdate_Exit:
Exit Sub
txtMCQnumber_AfterUpdate_Err:
MsgBox Err.Description, vbCritical, "Error"
Resume txtMCQnumber_AfterUpdate_Exit
End If