View Full Version : More Help Needed on Must Choose One (Sometimes)


DBennett
07-25-2000, 06:51 AM
In my form. I have a combo box. The choices in the box are: Service Agreement, Industrial Rent, Professional Services, and Misc.

If the user chooses Service Agreement or Industrial Rent a bunch of check boxes become visible. These choices are: Security, Landscape, Parking, and Custodial. The user may choose any of them or all of them. I need to know how to make him choose one of them at least.

The problem with the answer that I already received is that If the combo box choice is Professional Services or Misc. these check boxes still exist, they are just not visible. The user does not have to make a choice in this instance. Only if the boxes are visible.

Pat Hartman
07-25-2000, 05:38 PM
You need to place the edits in the BeforeUpdate event of the form. They will need to be based on the choice made in the combo box. So for example if Service Agreement is choosen, your code will check fld1, fld5, and fld7 and if none of them has a value, you can display a message box and cancel the update. Use a case statement for your basic structure with the individul field checks coded within the case.

Select Case me.cmbServiceType
Case "Service Agreement"
....If Len(fld1) = 0 and Len(fld5) = 0 and Len(fld7) = 0 then
........Cancel = True
........MsgBox "appropriate message", vbOKOnly
....End If
Case "Industrial Rent"
...
Case "Professional Services"
...
Case "Misc"
...
Case else
....Cancel = True
....MsgBox "You must choose a value for combo1", vbOkOnly
....me.combo1.SetFocus
End Select