How to make an unbound control required??

  • Thread starter Thread starter Amit
  • Start date Start date
A

Amit

Hi,

I have an unbound combo-box in a form (the form is not
based on any table or query). How can I force the user
select a value from the combo-box?? There's no 'required'
property for it.

The combo-box is the first control on the form. In
addition, there are 3 buttons to open different forms, but
all of them require the user to select a Program.

What I've tried so far:
1. In the 'Validation Rule', I have the following:
"=[cboProgramID_frmMenu_2].[Value] Is Not Null"

2. I tried putting code in the OnExit event of the
comboBox to check for the value, and if null, then set
focus to combo-box.

3. In the OnClick event of the button, I put code to check
for the value of combo-box and if null, then set focus to
combo-box and exit.

None of these worked. For 3., I get a syntax error for
missing ProgramID. But, that's not quite the message I'd
like to display as it's pretty cryptic.

Is there a better way to accomplish what I'm trying to do?
Am I missing something really simple here??

Thanks for any help.

-Amit
 
How you do it depends on where and when you want to enforce this. To enforce it using
events of the combo box, you'll need to ensure that the user goes to the combo box. If
they totally bypass the combo box, this won't work. If you only want to make sure that a
selection has been made before the record is saved then use the Form's BeforeUpdate event.
If the combo box is Null, then set Cancel = True and set focus to the combo box. You may
also want to use a Msgbox to inform the user of the problem.
 
---------- "Amit said:
The combo-box is the first control on the form. In
addition, there are 3 buttons to open different forms, but
all of them require the user to select a Program.

What I've tried so far:
1. In the 'Validation Rule', I have the following:
"=[cboProgramID_frmMenu_2].[Value] Is Not Null"

2. I tried putting code in the OnExit event of the
comboBox to check for the value, and if null, then set
focus to combo-box.

3. In the OnClick event of the button, I put code to check
for the value of combo-box and if null, then set focus to
combo-box and exit.

None of these worked. For 3., I get a syntax error for
missing ProgramID. But, that's not quite the message I'd
like to display as it's pretty cryptic.

Amit,

please post the code for 2. and 3., and the exact error message. The
error message has something to do with syntax error (probably from a
query built in code), so you have coding errors which must be
eliminated. Only after this can you see if the code really works.

Best regards
Emilia

Emilia Maxim
PC-SoftwareService, Stuttgart
http://www.maxim-software-service.de
 
Back
Top