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 SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Make a checkbox visible under certain conditions

Status
Not open for further replies.

jminn0311

Technical User
Jan 7, 2004
66
0
0
US
I have a subform with a combobox and checkbox. I would like to make the checkbox invisible if there is no value in the combobox. I can't seem to make this work by using the .visible function in the code. I know this is real simple, does anyone have a snippet of code or suggestions on how to make this work.

Thank you

Jeff M.
 
Code:
If IsNull([i]combobox[/i]) Then
       [i]checkbox[/i].Visible = False
Else
       [i]checkbox[/i].Visible = True
End If
Set the checkbox' visible property to false by default.
Then insert the above code in the afterupdate event of combobox.

Good Luck

Mike
 
That worked except the subform is a continous form of multiple records and I only want the checkbox to show on the records where there is a value in the combo box. Any other suggestions?

thanks,
Jeff M.
 
How are ya jminn0311 . . . . .

Unfortunately you can't use [blue]Conditional Formatting[/blue] on a checkbox . . . . Sorry for the bad news . . .



Calvin.gif
See Ya! . . . . . .
 
Jeff

Is the combo box and the check box "bound" to the table? (Data in the chombo box corresponds to a field on the table, and the check box referes to a yes/no field on the table)

If so, then yes you can make this work.

If the form objects are not bound, then achieving this outcome is not easy.

For the AfterUpdate event procedures and for the OnCurrent event procedure...

Code:
'If combo box is bound to a numeric value
Me.YourCheckBox.Visible = Not (Nz(Me.YourComboBox, 0))

'If combo box is bound to a text string
Me.YourCheckBox.Visible = Not (Len(Nz(Me.YourComboBox, "")))

Richard
 
How are ya willir . . . . .
jminn0311 said:
[blue]That worked except the [purple]subform is a continous form[/purple] of multiple records and I only want the [purple]checkbox to show[/purple] on the records [purple]where there is a value[/purple] in the combo box[/blue]

The [blue]Visible Property[/blue] hides them all and is not included in [blue]Conditional Formatting[/blue], the [purple]Enabled Property[/purple] is. But again, [purple]you can't Conditional Format a CheckBox[/purple] . . . . .

Calvin.gif
See Ya! . . . . . .
 
Hi AceMan

Whoops - you are correct.[blush]

I knew I had resolved the problem in the past, but I forgot one small thing - I had changed the check box to a combo box. (Value list True/False Yes/No, bound to a boolean yes/no field on the table with conditional formatting)
 
jminn0311 . . . . .

[blue]willir[/blue] has a good idea there. [blue]Change the CheckBox to a Combobox[/blue] with a [purple]Value List[/purple] for selection. Then setup Conditional Formatting. You can't hide the Combobox but you can disable it (that disabled look & inactive).

Way ta go [blue]willir![/blue] ;-)

Calvin.gif
See Ya! . . . . . .
 
Thank you for all the tips. I am going to try the latter as yes/no will work in this situation. I will reply back with the results.

Thanks again,

Jeff M.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top