Validation on subform that you can't leave option blank

aman

Registered User.
Local time
Today, 06:24
Joined
Oct 16, 2008
Messages
1,251
Hi All

I have a form and within that there is a sub form. The subform displays

Assessment questions, Scoring(Yes,No,N/A) and Notes.

I want to put some validation on scoring so that the users need to select at least one option from (Yes,No,N/A) options for each question. They can't leave the scoring blank for any of the questions.

Any help will be much appreciated .

Thanks
 
Is the scoring an option group or a combobox, or separate fields?
 
its an option group with 3 options in it .
 
There are a few ways to do this, the simplest one is to set a default value on the option group.

The other one would be to use the Before_update event of the form. if your option group is called optAnswer then code something like
Code:
Private Sub Form_BeforeUpdate(Cancel As Integer)
	
	If isnull(Me.optAnswer) or Me.optAnswer = 0 Then
		msgbox"No answer provided"
		'[COLOR="Teal"][COLOR="Green"]put code in here to goto the missing answer control[/COLOR][/COLOR]
		exit sub
	End If
	
	[COLOR="green"]'do something here to save your record - got to the next record etc.
	[/COLOR]
End Sub
 

Users who are viewing this thread

Back
Top Bottom