Control buttons - stay visible

Mahall906

New member
Local time
Today, 15:49
Joined
Apr 11, 2014
Messages
29
On my form I have a checkbox called "owner" and when it is checked a button is shown. The code I use is:

Private Sub Owner_AfterUpdate()
If owner = True Then
Command2162.Visible = True
Else
Command2162.Visible = False
End If
End Sub

This works; however, when I leave the form, and that record, then go back into it, the button does not stay visible. How can I make that button stay visible when that checkbox remains checked?

I have the "Visible" control set to "No".

Any help as always would be appreciated ;-)
 
Give your controls some decent names :( Command 2162 ?
You would need to use the same code, or make it a sub and call it from the afterupdate of the Owner control and the Forum Current event I would expect.
 
you can simplify your code

Code:
Private Sub Owner_AfterUpdate()

    Command2162.Visible = owner = True

End If

and as Gasman says, in the form current event

Code:
Private Sub Form_Current()
  
  Owner_AfterUpdate

End Sub
 
Perfection! Thank you both!

As simple as that. This forum it excellent! ;-)
 
Me again!
Now the visible options are working great; however, it will not allow me to open a new blank form to enter information. It allows be to open a form already completed.
Am I missing something obvious?

I get:
Run-time error '94':
Invalid use of Null

Thanks again
 
You need to put that code in OnCurrent event of the form.
Now you will have this code in two event: AfterUpdate event of the control and OnCurrent event of the form.
 
Owner is a Boolean but each to their own
 
it will not allow me to open a new blank form to enter information. It allows be to open a form already completed.
Am I missing something obvious?

I get:
Run-time error '94':
Invalid use of Null

depends on the code you are using to open the form
 
@CJ_London Thanks, I didn't notice that.

@Mahall906 You need to check to see if this is a new record first.

Code:
If Me.NewRecord Then
    Me.Command2162.Visible = False
Else
    Me.Command2162.Visible = owner
End If
Thanks Pat Hartman, may seem a daft question, but where would I need to put this bit of code, in the Form_Current?
 
You need to put that code in OnCurrent event of the form.
Now you will have this code in two event: AfterUpdate event of the control and OnCurrent event of the form.
Thanks, I did this and works great. Its just the new record bit now.
 
I've only gone and done it! Spent a while, worked it out and happy! Again, thank you!! (y)
 

Users who are viewing this thread

Back
Top Bottom