checkbox to enable/diable other fields

  • Thread starter Thread starter firecop1
  • Start date Start date
F

firecop1

Hi all,
I have a check box on my form called "Permits" that if checked I would like
a button to appear that will allow users to view the permit info. If the box
is unchecked I want the button to be invisible.

Thanks in advance to this awesome group for your help.

Andrew J. Brofman
Chief Fire Marshal
Lake Grove, NY
 
The Checkbox needs to be bound to a Yes/No field in your underlying table,
with the Default Value set as = No.

The Visible Property for the command button (called ViewPermits in this
example) has to be set to No. Then place this code in the form's code module:

Private Sub Form_Current()
If Permits Then
ViewPermits.Visible = True
Else: ViewPermits.Visible = False
End If
End Sub

Private Sub Permits_Click()
If ShowButton Then
ViewPermits.Visible = True
Else: ViewPermits.Visible = False
End If
End Sub

Good Luck, Chief!
 
Sorry, that second sub should read

Private Sub Permits_Click()
If Permits Then
ViewPermits.Visible = True
Else: ViewPermits.Visible = False
End If
End Sub

I'd used another name for the checkbox when I was running up the code and
forgot to change it to your name of Permits before posting!
 
Thanks for the response,
I am going to give it a try now and see what happens.

Andrew J. Brofman
Chief Fire Marshal
Lake Grove, NY
 
Wow that worked as described thank you!!!
Now let me press my luck here. I have a second check box on the same form as
the first, this one called "rental" that if checked I would like a button to
appear that will allow users to view the rental info in a popup form. If the
box
is unchecked I want the button to be invisible.

Taking your previous advice, I set the default value to "No" in my table and
the Visible property for the command button to "No".
Being adventerous I tried to duplicate your code substituting the name of
this button and field for the other yet I could not get it to work and
received an error.

Do I have to do something different to this one and if so is it because the
two codes are fighting with each other?

Thanks again.

Andrew J. Brofman
Chief Fire Marshal
Lake Grove, NY
 
We'll need to see your code, and the error message would be good too!

--
There's ALWAYS more than one way to skin a cat!

Answers/posts based on Access 2000

Message posted via AccessMonster.com
 
Ok so I played around with the code and got it to work by combining both
routines under one Private Sub Form_Current()
I had originally had two but now I have them both under one.

The weird thing is that when the button is enabled and I click on it does
not filter the viewable records in the rental or permits form to match the
record in the main form..Is there a pop up form wizard similar to the
subform wizard??


I am using Access 2007 BTW

Andy
 
The pop up form wizard in this case would be Chief Andy! You'll need to alter
the way in which you open your new forms so that they open to the desired
record(s). Since you've solved your original problem ("checkbox to
enable/diable other fields") you need to post a new question, with an
appropriate title, so everyone here can see what you're having trouble with.
Simply state what you're trying to do, giving brief details, such as what
field connects the calling form and the popup being called, and its datatype
(whether text or numerical) and like that.

I'm only going to be online intermittantly for the next three days, but I'll
keep an eye out, and there are a bunch of other really good people here. One
word to the wise; ignore any and all replies from a poster named "Aaron
Kemph" aka "Steve!" He's an agitator that gives advice that 9/10 of the time
is wrong and always anti-Access!

Have a good day!

--
There's ALWAYS more than one way to skin a cat!

Answers/posts based on Access 2000

Message posted via AccessMonster.com
 
Yeah he sent me a private email telling me that if I need a database
developed he would do it for me (for a price of course). I happened to be
reading through some other posts and noticed a few comments directed at him
so I just ignored it.

I really appreciate all of the help you have given me here. These groups
provide one hell of a tool for amateurs to build their own databases and as
you can see I would be lost without it.

I will post a new question as you suggested and see where it goes.

Andy
 
Back
Top