Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Check a form to make sure it's completed

Status
Not open for further replies.

djburnheim

Technical User
Jan 22, 2003
71
0
0
AU
I have a form with about 20 questions and Yes/No option buttons...when the user clicks OK I want to call a procedure to check that all questions have been answered and if there are any "No" answers...I have code that will check all the option buttons but it only works if the user has answered yes.

Dim ctrl As Control
Dim Complete As Boolean

'Check to see if all checks have been done
For Each ctrl In frmUserForm.Controls
If TypeName(ctrl) = "OptionButton" Then
If ctrl = False Then
Complete = False
Else
Complete = True
End If
End If
Next ctrl

If Complete = True Then
frmChecklist.cmdOK.Enabled = True
End If
 
Something like this ?
Dim ctrl As Control
Dim Complete As Boolean
Complete = True
'Check to see if all checks have been done
For Each ctrl In frmUserForm.Controls
If TypeName(ctrl) = "OptionButton" Then
If ctrl = False Or IsNull(ctrl) Then
Complete = False
Exit For
End If
End If
Next ctrl
If Complete = True Then
frmChecklist.cmdOK.Enabled = True
End If

Hope This Helps, PH.
Want to get great answers to your Tek-Tips questions? Have a look at FAQ219-2884 or FAQ222-2244
 
thanks PH but still doesn't work and I also need to be able to determine if the user has answered NO to any questions.

I'm trying different things but if anybody has got any suggestions it would be great.

many thanks
Dave
 
still doesn't work
What do you expect ?
If Complete = False then at least one question is either answered No or not answered at all.

Hope This Helps, PH.
Want to get great answers to your Tek-Tips questions? Have a look at FAQ219-2884 or FAQ222-2244
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top