forms problem

  • Thread starter Thread starter froto
  • Start date Start date
F

froto

Let me try this one from a different angle. What code
would I need to acheive the following. I have checkboxes
on my form that once a user selects a checkbox their are
several textboxes below the checkbox that require data.
What happens now is users forget to fill in all of the
required textboxes, and what I would like is once they
select the submit button, it would check for any
checkboxes that have been selected, and that all the
required texboxes have values in them (textboxes that
follow below each checkbox). If not it would return a
error message telling them which ones they have missed
and would require them to enter values in them before
they can submit the form.

Thanks for all your help you guys are swell.
 
froto said:
Let me try this one from a different angle. What code
would I need to acheive the following. I have checkboxes
on my form that once a user selects a checkbox their are
several textboxes below the checkbox that require data.
What happens now is users forget to fill in all of the
required textboxes, and what I would like is once they
select the submit button, it would check for any
checkboxes that have been selected, and that all the
required texboxes have values in them (textboxes that
follow below each checkbox). If not it would return a
error message telling them which ones they have missed
and would require them to enter values in them before
they can submit the form.


Use the submit button's Click event to run the code. If you
don't use a submit button, then the code should go into the
Form's BeforeUpdate event.

strMsg = ""
If chkbox1 = True Then
If IsNull(textbox1a) Then
strMsg = strMsg & ", textbo1a"
End If
If IsNull(textbox1b) Then
strMsg = strMsg & ", textbo1b"
End If
. . .
End If
If chkbox2 = True Then
If IsNull(textbox1a) Then
strMsg = strMsg & ", textbo2a"
End If
If IsNull(textbox1b) Then
strMsg = strMsg & ", textbo2b"
End If
. . .
End If
. . .
If strMsg <> "" Then
MsgBox "You must provide a value for " & Mid(strMsg, 3)
Exit Sub
End If
' everything has a value, save the record
If Me.Dirty Then Me.Dirty = False
End Sub
 
Back
Top