This is everything in frmFail
Dim strFailReason As String
Private Sub UserForm_Initialize()
Dim answercount As Integer
Dim howmanyitems As Integer
Dim thisitem As String
Dim vFails As Variant
Dim a As Integer, b As Integer, possanswers As Integer
Dim tmpSQL As String
LbxFailReason.Clear
possanswers = 0
For a = 1 To UBound(varFailRsn, 1)
If (varFailRsn(a, 1) = strQstn) Then
LbxFailReason.AddItem varFailRsn(a, 2)
possanswers = possanswers + 1
End If
Next a
LbxFailReason.AddItem "Other"
If (Mid(AllQuestionsComplete, Val(strQstn), 1) = "F") Then
tmpSQL = "SELECT Fail_Reason FROM tblFails WHERE ((tblFails.CaseID = " & currCaseID & ") AND (tblFails.Question = " & strQstn & "));"
Call TableAccess(tmpSQL, vFails)
If (Empty_Array(vFails)) Then
'do nowt
Else
For answercount = 0 To possanswers
thisitem = LbxFailReason.Column(0, answercount)
For b = 0 To UBound(vFails, 2)
If (vFails(0, b) = thisitem) Then
LbxFailReason.Selected(answercount) = True
End If
Next b
Next answercount
End If
End If
Me.btnFailResonSave.SetFocus
Mid(AllQuestionsComplete, Val(strQstn), 1) = "F"
End Sub
Private Sub btnFailResonSave_Click()
Dim boolOther As Boolean
Dim failreasons(20) As Variant
Dim tempcount As Integer
intNOTREFRESH = 1
intQuestion = Val(strQstn)
If LbxFailReason.ListIndex = -1 Then
MsgBox ("No Failure Reason Selected")
Else
For tempcount = 0 To countFails
If (varAllFails(tempcount, 0) = intQuestion) Then
varAllFails(tempcount, 0) = 0
varAllFails(tempcount, 1) = ""
End If
Next tempcount
'tempcount = tempcount + 1
'initialise and reset the variables and array for the question
intFails = 2
For x = 0 To 50
strQFail(intQuestion, x) = ""
Next x
failreasons(1) = "DELETE CaseID FROM tblFails WHERE ((tblFails.CaseID = " & currCaseID & ") AND (tblFails.Question = " & intQuestion & "));"
'cycle through the Failure reasons adding the selected items to the questions array.
For i = 0 To Me.LbxFailReason.ListCount - 1
If Me.LbxFailReason.Selected(i) Then
varAllFails(tempcount, 0) = intQuestion
varAllFails(tempcount, 1) = Me.LbxFailReason.List(i)
tempcount = tempcount + 1
failreasons(intFails) = "INSERT INTO tblFails ( CaseID, Question, Fail_Reason ) SELECT " & currCaseID & ", " & intQuestion & ", '" & Me.LbxFailReason.List(i) & "';"
If (Me.LbxFailReason.List(i) = "Other") Then
boolOther = True
End If
intFails = intFails + 1
End If
' save the info
Call InsertArrayload(failreasons, intFails)
frmFail.Hide
If (boolOther) Then
frmOther.Show
Else
'do nowt
End If
NoteQNo = strQstn
frmNewNote.Show
Unload frmFail
End If
End Sub
Bookmarks