Hide textboxes if checkbox selected

  • Thread starter dropdown3 via AccessMonster.com
  • Start date

D

dropdown3 via AccessMonster.com

My form has a check box for Coin and one for Currency. When you click the
check box for coin, I would like it to hide the currency denomination
textbox. When you check the box for currency, I would like it to hide all of
the coin textboxes.

If Coin (Coin = 385) is selected, allow these textboxes:
[Pennies] [Nickels] [Dimes] [Quarters] [Dollars] [Halves] [Rolled Coin]
[Boxed Coin]

If Currency (Currency = 390) selected only allow this textbox:
[Currency]

There are other controls and textboxes on the form so I want to keep them
accessible, but these are the ones that directly relate to either coin being
selected or currency being selected.

Chuck
 
Ad

Advertisements

G

Guest

Since Coin and Currency are exclusive of one another, I suggest you put those
two check boxes in an option group. Set the Coin option value to 1 and the
Currency option value to 2. Then in the After Update event of the option
group:

With Me
.[Pennies].Visible = .OpgMoney = 1
.[Nickels].Visible = .OpgMoney = 1
.[Dimes].Visible = .OpgMoney = 1
.[Quarters].Visible = .OpgMoney = 1
.[Dollars].Visible = .OpgMoney = 1
.[Halves].Visible = .OpgMoney = 1
.[Rolled Coin].Visible = .OpgMoney = 1
.[Currencty]..Visible = .OpgMoney said:
[Boxed Coin]


dropdown3 via AccessMonster.com said:
My form has a check box for Coin and one for Currency. When you click the
check box for coin, I would like it to hide the currency denomination
textbox. When you check the box for currency, I would like it to hide all of
the coin textboxes.

If Coin (Coin = 385) is selected, allow these textboxes:
[Pennies] [Nickels] [Dimes] [Quarters] [Dollars] [Halves] [Rolled Coin]
[Boxed Coin]

If Currency (Currency = 390) selected only allow this textbox:
[Currency]

There are other controls and textboxes on the form so I want to keep them
accessible, but these are the ones that directly relate to either coin being
selected or currency being selected.

Chuck
 
D

dropdown3 via AccessMonster.com

No luck. The two check boxes are in option group Frame0. Here is the current
code along with the new code that doesn't work:

Private Sub Currency_AfterUpdate()

End Sub

Private Sub Frame0_AfterUpdate()
If Me!Frame0 = 385 Then
DoCmd.GoToControl "Pennies"
End If
If Me!Frame0 = 390 Then
DoCmd.GoToControl "Currency"
End If
End Sub

With Me
.[Pennies].Visible = .Frame0 = 385
.[Nickels].Visible = .Frame0 = 385
.[Dimes].Visible = .Frame0 = 385
.[Quarters].Visible = .Frame0 = 385
.[Dollars].Visible = .Frame0 = 385
.[Halves].Visible = .Frame0 = 385
.[Rolled Coin].Visible = .Frame0 = 385
.[Currency].Visible = .Frame0 <> 390
End With

Hopefully, this is something simple because I'm not very good with this.

Chuck
 
G

Guest

doesn't work? What does it do or not do?
What are the Option Values for the check boxes in Frame0?
Each check box will have a value it returns. The Option Value of the
selected check box in Frame0 will be what is returned when you test it. It
must be an integer value. Usually, it is 1,2,3,4, etc; however, setting it
to 385 and 390 should work. Here are some modifications to your code that
may solve the problem:

Private Sub Frame0_AfterUpdate()
With Me
.[Pennies].Visible = .Frame0 = 385
.[Nickels].Visible = .Frame0 = 385
.[Dimes].Visible = .Frame0 = 385
.[Quarters].Visible = .Frame0 = 385
.[Dollars].Visible = .Frame0 = 385
.[Halves].Visible = .Frame0 = 385
.[Rolled Coin].Visible = .Frame0 = 385
.[Currency].Visible = .Frame0 = 390

If Me!Frame0 = 385 Then
.[Pennies].SetFocus
Else
.[Currency].SetFocus
End If
End With
End Sub
 
Ad

Advertisements

D

dropdown3 via AccessMonster.com

I deleted all the code except:

Private Sub Frame0_AfterUpdate()
With Me
.[Pennies].Visible = .Frame0 = 385
.[Nickels].Visible = .Frame0 = 385
.[Dimes].Visible = .Frame0 = 385
.[Quarters].Visible = .Frame0 = 385
.[Dollars].Visible = .Frame0 = 385
.[Halves].Visible = .Frame0 = 385
.[Rolled Coin].Visible = .Frame0 = 385
.[Boxed Coin].Visible = .Frame0 = 385
.[Currency].Visible = .Frame0 = 390

If Me!Frame0 = 385 Then
.[Pennies].SetFocus
Else
.[Currency].SetFocus
End If
End With
End Sub

This works great! No more keying errors hopefully.

Chuck
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top