Field selection makes button appear

spalmateer

Registered User.
Local time
Today, 15:37
Joined
Dec 5, 2000
Messages
46
Hello,
I have a customer form with a Yes/No checkmark box. I would like if the box is checked, for a button to be visible that allows the user to go to a form. Please forgive my ignorance as I'm sure there's probably a very easy way to do this. Thanks in advance for the help and insight.
Scott
 
The following code works using the OnClick event of the Check Box property
chkTest is the name of the Check Box
cmdView is the name of the button


Private Sub chkTest_Click()
If Me.chkTest.Value = True Then
Me.cmdView.Visible = True
Else
Me.cmdView.Visible = False
End If
End Sub

HTH

Simon
 
The answer from simongallop will work fine, but below is a solution I use to setting the visible property for controls on forms.

All you have to do is put a value in the TAG property of the control (say NORMAL for demo purposes) for every control that you want to hide or unhide and use the code below.

Its also useful for changing the colours of controls under certain circumstances, and stops you having to list a whole collection of controls in your code, reducing workload!

**************code below***********

Dim MyControl As Control

If Me.chkTest.Value = True Then
For Each MyControl In Form.Controls
If MyControl.Properties("Tag") Like "[Name of your tag here]" Then
MyControl.Visible = True
End If
Next
Else
For Each MyControl In Form.Controls
If MyControl.Properties("Tag") Like "[Name of your tag here]" Then
MyControl.Visible = False
End If
Next
Endif
 
Adam, hope that you can help. If many controls need changing then I also use the TAG property, but I use:

If MyControl.Tag = "[Name of TAG]" then

instead of

If MyControl.Properties("Tag") Like "[Name of your tag here]" Then

Having never used LIKE, except in queries, are there advantages to using it in VB and if so could you let me know

Thanks in advance

Simon
 
Simon,

The advantage of like is that with queries it will find all instances of "NORMAL" for instance( NORMAL, NORMAL2, NORMAL3) so that you can with one section of your code turn off all the "NORMAL" controls, but then turn on "NORMAL2" later by using = "NORMAL2". Thats how I use it anyway.

Adam
 
Thanks Adam. So basicaly LIKE in your NORMAL example is the same as saying NORMAL*
 

Users who are viewing this thread

Back
Top Bottom