Lars
Lars

Reputation: 11

How do I properly use if/then for a bolean value in order to make an object visible?

I want to display an endless access form. For each data set there is a yes/no value (PA). If yes, then a hidden object should be displayed. It seems very straight forward, but it doesn't work.

I have tried by changing the value of PA to 1, 0, -1. Either nothing happens, or the object will be displayed for all data sets.

The object is defined as hidden in the form.


Private sub form_current()

If PA.value = true Then
 me.object.visible = True
End if

End Sub

I would be very happy for some advice. /LP

Upvotes: 1

Views: 49

Answers (2)

Gustav
Gustav

Reputation: 55841

As the object is unbound, you can't do this. When unbound, it will either be visible or not - for all records.

One workaround is to move the control to a tiny subform having a master/child relation to the main form.

Upvotes: 1

Mathieu Guindon
Mathieu Guindon

Reputation: 71187

Handle the control's Change event, and then you can assign to its value:

Private Sub PA_Change()
    Me.object.Visible = PA.Value ' TODO: give 'object' an actual name
End Sub

Find PA in the top-left codepane dropdown, then select the Change event in the top-right code pane dropdown if it's not automatically selected - the VBE will generate the event handler procedure for you.

Upvotes: 2

Related Questions