Button hide/show trouble

tjones

Registered User.
Local time
Today, 09:00
Joined
Jan 17, 2012
Messages
199
I am attempting to have a button become visible when "Option79" the NO option button is selected.

Private Sub Option79_ongotfocus()
If Me.Option79 = true Then
Me.cmdInter.Visible = True
Else
Me.cmdInter.Visible = False
End If

I am getting a run time error 2427

I also attempted to do so using a macro which did not work either.
 
Last edited:
The following line is in error:

Code:
Private Sub Degree_Type_ongotfocus()

change it to:

Code:
Private Sub Degree_Type_GotFocus()

Try the code that runs on the Click Event Procedure of Option79 control as shown below:
Code:
Private Sub Option79_Click()
If Me.Option79 Then
    Me.cmdInter.Visible = True
Else
    Me.cmdInter.Visible = False
End If
End Sub
 
The above did not work. Maybe i'm not stating what I need clearly.

ON OPEN of a new record the cmdInternational button needs to be hidden

On CURRENT/AFTER UPDATE if the USNo option (2 for no in the table - see mockup of option setup below) is selected then the cmdInternational button needs to be visible.

--US-----
| () Yes |
| () No |
 
Your post is not really clear; is the Option Group named Option79 or USNo? You appear to use one name in one post and another in another! I'll use USNo in the examples below:
Code:
Private Sub Form_Current()
 If Me.USNo = 2 Then
  cmdInternational.Visible = True
 Else
  cmdInternational.Visible = False
 End If
End Sub
Code:
Private Sub USNo_AfterUpdate()
If Me.USNo = 2 Then
  cmdInternational.Visible = True
 Else
  cmdInternational.Visible = False
 End If
End Sub
Linq ;0)>
 
Sorry the option group "US Citizen" with Yes (option95) and No (otpion97) i renamed the buttons to 95 to USYes and 97 to USNo.

The problem is that when a new form opens there is no entry/selection for the option = 2 is not valid code and keeps resulting in the error 2472. I tried changing the =2 to ' ' an empty but it still give a "compile error" expected expression.

I think the one set should go under form On Current and the other should go under either After Update or the field On focus.

I just can't make any combination work.
 
Last edited:
So this isn't an Option Group, where only one Option at a time can be ticked?
 
yes it's an option group. in the table yes =1 and no=2 and you can only choose one of the options.

it is using the forms design -xyz- option. I tried to post graphic but the forum won't let me. though it does look something like this

| ------XYZ------|
| () Yes |
| () No |
-----------------------

with them being round raido option type buttons.
 
If it is an OptionGroup then simply replace USNo where it appears in my code with the actual name of the Group. When placing an Option Group on a Form, Access assigns it a Name such as FrameX to it, where the X varies. So, once again, be sure to replace USNo in my code with the actual name!

Linq ;0)>
 

Users who are viewing this thread

Back
Top Bottom