Solved Checking if all assessment questions have been answered in the subform (1 Viewer)

Derek

Registered User.
Local time
Yesterday, 21:56
Joined
May 4, 2010
Messages
234
Hi All,

I have a subform within a form that pulls through all the assessment questions . There is a frame with 3 options (Yes/No/NA)for each question . I was wondering the below validations can be added :
1.None of the questions are left unanswered by the users when they press Save button
2. Also if any of the question is answered as ‘No’ then display message "Non competent Call"

Any help will be much appreciated . Thanks :)
 

bob fitz

AWF VIP
Local time
Today, 05:56
Joined
May 23, 2011
Messages
4,727
IMHO the best place for your validation code is the Before Update event of the subform.
 

gemma-the-husky

Super Moderator
Staff member
Local time
Today, 05:56
Joined
Sep 12, 2006
Messages
15,658
I would convert the selected response to a number, 1,2,3 and store the number
Then any questions with a value of 0 have not been answered. Any values of 2 have been answered as "No".
 

Derek

Registered User.
Local time
Yesterday, 21:56
Joined
May 4, 2010
Messages
234
I have written the following validation code but it works if none of the assessment questions are answered but if one of them is answered then the code doesn't check for other unanswered questions :
Code:
Private Function ValidateForm() As Boolean
Dim strString As String
Dim strsql As String
If Me.sfrm_CallAudit_Matrix.Controls("FraOption") = 0 Then
strString = strString & vbCrLf & "Scoring in Customer Outcome section."
End If

If Me.sfrm_CallAudit_Customer.Controls("FraOption") = 0 Then
strString = strString & vbCrLf & "Scoring in Customer experience section."
End If

If strString = "" Then
   ValidateForm = True
Else
    MsgBox "Form Incomplete, please enter values in the following fields" & vbCrLf & strString
    ValidateForm = False
End If

End Function
 

jdraw

Super Moderator
Staff member
Local time
Today, 00:56
Joined
Jan 23, 2006
Messages
15,379
Does your option group have a default value?

If not, then you might try something along the following (untested air code)

Code:
For each ctl in Me.sfrm_CallAudit_Customer.Controls
  if ctl.controltype =acOptionGroup then

    if isNull(ctl) then  iUnanswered = iUnanswered +1
  end if
next ctl
if iUnanswered >0 then .....
 

MajP

You've got your good things, and you've got mine.
Local time
Today, 00:56
Joined
May 21, 2018
Messages
8,536
do a dcount using the same criteria that is used on the subform. I am guessing questions are assigned to a user and the main form is the user.
Something like
if dcount("*","sometable", "USerID = " & Me.USerID & " AND QuestionScore is Null") > 0 then
do something because you have an unanswered question for the selected user.
 

Derek

Registered User.
Local time
Yesterday, 21:56
Joined
May 4, 2010
Messages
234
Thanks MajP. I managed to fix the issue !
 

Users who are viewing this thread

Top Bottom