Activate button control with option box

  • Thread starter Thread starter Robbin
  • Start date Start date
R

Robbin

Hi all,

I hope I'm not duplicating a previous question, but I didn't find it when I
searched.

I have a button on a form that activates a pop-up sub-form. I would like
for the button to remain activated or deactivated (greyed out) based on
option box selections.
Here are the option box selections:
1 Tenured
2 Tenure Approved
3 Tenure Track
4 Non-tenure Track
5 Neither
The option box and the control are on the same form.
I would like the button to be active based on the option box numbers 1, 2,
or 3 and deactive for the rest. If it can't be greyed out, then I guess I
would need a pop-up dialog box telling the user why the button is not active.

Not sure were to set the event or what the code should look like.

Thank you!
 
Use the After Update event of the Option Group

Me.MyButton.Enabled = Me.MyOptionGroup < = 3

If the option group is a bound control, you will also need to put the same
line of code in the form Current event.
 
Thank you so much. That worked beautifully. I have another more complex
question about a switch or if statement, but it may be too complicated to
type it all here. Any suggestions?
 
Thank you, before I go on, I discovered a problem with the option group
above. When I try to add a new record I get a SQL error - "Invalid Use of
Null". Naturally, it's easily overcome by creating the record, but not very
elegant.

I'll try to compose my other question in a later post.

Thank you again!
 
Sounds like the option group is a bound control. Try setting the default
value of the option group to a valid value.
 
Thank you, Klatuu. I'm very proud of myself! I actually thought to do that
just after I sent the question, but I'm afraid it doesn't work. Once I type
anything into any field, it activates the default value for the option group.
Problem solved. But by then it's too late.--
Robbin
 
That doesn't seem right. The Default value of a bound control is only
assigned to new records. Anything you enter in the control after the record
has been created will override the default value.

Post the code where the null value error is occuring, please.
 
Klatuu,

You are right, I misspoke. I meant once I've typed into any OTHER field,
the error is resolved (thus creating a new record). But that is actually the
case whether I use the default value or not.

Here is the code including and following the error.

Private Sub Form_Current()
Me.Tenure_Form_Button.Enabled = Me.Frame111 <= 3
End Sub


Private Sub Frame111_AfterUpdate()
Me.Tenure_Form_Button.Enabled = Me.Frame111 <= 3
End Sub

Private Sub Tenure_Form_Button_Click()
On Error GoTo Err_Tenure_Form_Button_Click

Dim stDocName As String
Dim stLinkCriteria As String

stDocName = "Tenure Track Form"

stLinkCriteria = "[ID]=" & Me![ID]
DoCmd.OpenForm stDocName, , , stLinkCriteria

Exit_Tenure_Form_Button_Click:
Exit Sub

Err_Tenure_Form_Button_Click:
MsgBox Err.Description
Resume Exit_Tenure_Form_Button_Click

End Sub
 
You did not show which line of code is causing the error. Also, change this
code:
Private Sub Form_Current()
Me.Tenure_Form_Button.Enabled = Me.Frame111 <= 3
End Sub

To
Private Sub Form_Current()
If Not Me.NewRecord Then
Me.Tenure_Form_Button.Enabled = Me.Frame111 <= 3
End If
End Sub


--
Dave Hargis, Microsoft Access MVP


Robbin said:
Klatuu,

You are right, I misspoke. I meant once I've typed into any OTHER field,
the error is resolved (thus creating a new record). But that is actually the
case whether I use the default value or not.

Here is the code including and following the error.

Private Sub Form_Current()
Me.Tenure_Form_Button.Enabled = Me.Frame111 <= 3
End Sub


Private Sub Frame111_AfterUpdate()
Me.Tenure_Form_Button.Enabled = Me.Frame111 <= 3
End Sub

Private Sub Tenure_Form_Button_Click()
On Error GoTo Err_Tenure_Form_Button_Click

Dim stDocName As String
Dim stLinkCriteria As String

stDocName = "Tenure Track Form"

stLinkCriteria = "[ID]=" & Me![ID]
DoCmd.OpenForm stDocName, , , stLinkCriteria

Exit_Tenure_Form_Button_Click:
Exit Sub

Err_Tenure_Form_Button_Click:
MsgBox Err.Description
Resume Exit_Tenure_Form_Button_Click

End Sub

--
Robbin


Klatuu said:
That doesn't seem right. The Default value of a bound control is only
assigned to new records. Anything you enter in the control after the record
has been created will override the default value.

Post the code where the null value error is occuring, please.
 
Hi Klatuu,

It was the first line -- sorry. But your addition fixed the problem (as you
suspected it would) :-)

Thank you very much!
--
Robbin


Klatuu said:
You did not show which line of code is causing the error. Also, change this
code:
Private Sub Form_Current()
Me.Tenure_Form_Button.Enabled = Me.Frame111 <= 3
End Sub

To
Private Sub Form_Current()
If Not Me.NewRecord Then
Me.Tenure_Form_Button.Enabled = Me.Frame111 <= 3
End If
End Sub


--
Dave Hargis, Microsoft Access MVP


Robbin said:
Klatuu,

You are right, I misspoke. I meant once I've typed into any OTHER field,
the error is resolved (thus creating a new record). But that is actually the
case whether I use the default value or not.

Here is the code including and following the error.

Private Sub Form_Current()
Me.Tenure_Form_Button.Enabled = Me.Frame111 <= 3
End Sub


Private Sub Frame111_AfterUpdate()
Me.Tenure_Form_Button.Enabled = Me.Frame111 <= 3
End Sub

Private Sub Tenure_Form_Button_Click()
On Error GoTo Err_Tenure_Form_Button_Click

Dim stDocName As String
Dim stLinkCriteria As String

stDocName = "Tenure Track Form"

stLinkCriteria = "[ID]=" & Me![ID]
DoCmd.OpenForm stDocName, , , stLinkCriteria

Exit_Tenure_Form_Button_Click:
Exit Sub

Err_Tenure_Form_Button_Click:
MsgBox Err.Description
Resume Exit_Tenure_Form_Button_Click

End Sub

--
Robbin


Klatuu said:
That doesn't seem right. The Default value of a bound control is only
assigned to new records. Anything you enter in the control after the record
has been created will override the default value.

Post the code where the null value error is occuring, please.
--
Dave Hargis, Microsoft Access MVP


:

Thank you, Klatuu. I'm very proud of myself! I actually thought to do that
just after I sent the question, but I'm afraid it doesn't work. Once I type
anything into any field, it activates the default value for the option group.
Problem solved. But by then it's too late.--
Robbin


:

Sounds like the option group is a bound control. Try setting the default
value of the option group to a valid value.
--
Dave Hargis, Microsoft Access MVP


:

Thank you, before I go on, I discovered a problem with the option group
above. When I try to add a new record I get a SQL error - "Invalid Use of
Null". Naturally, it's easily overcome by creating the record, but not very
elegant.

I'll try to compose my other question in a later post.

Thank you again!
--
Robbin


:

Go ahead and post the question. Without some detail, I can't offer a
suggestion.
--
Dave Hargis, Microsoft Access MVP


:

Thank you so much. That worked beautifully. I have another more complex
question about a switch or if statement, but it may be too complicated to
type it all here. Any suggestions?
--
Robbin


:

Use the After Update event of the Option Group

Me.MyButton.Enabled = Me.MyOptionGroup < = 3

If the option group is a bound control, you will also need to put the same
line of code in the form Current event.
--
Dave Hargis, Microsoft Access MVP


:

Hi all,

I hope I'm not duplicating a previous question, but I didn't find it when I
searched.

I have a button on a form that activates a pop-up sub-form. I would like
for the button to remain activated or deactivated (greyed out) based on
option box selections.
Here are the option box selections:
1 Tenured
2 Tenure Approved
3 Tenure Track
4 Non-tenure Track
5 Neither
The option box and the control are on the same form.
I would like the button to be active based on the option box numbers 1, 2,
or 3 and deactive for the rest. If it can't be greyed out, then I guess I
would need a pop-up dialog box telling the user why the button is not active.

Not sure were to set the event or what the code should look like.

Thank you!
 
Great, now for your next question
--
Dave Hargis, Microsoft Access MVP


Robbin said:
Hi Klatuu,

It was the first line -- sorry. But your addition fixed the problem (as you
suspected it would) :-)

Thank you very much!
--
Robbin


Klatuu said:
You did not show which line of code is causing the error. Also, change this
code:
Private Sub Form_Current()
Me.Tenure_Form_Button.Enabled = Me.Frame111 <= 3
End Sub

To
Private Sub Form_Current()
If Not Me.NewRecord Then
Me.Tenure_Form_Button.Enabled = Me.Frame111 <= 3
End If
End Sub


--
Dave Hargis, Microsoft Access MVP


Robbin said:
Klatuu,

You are right, I misspoke. I meant once I've typed into any OTHER field,
the error is resolved (thus creating a new record). But that is actually the
case whether I use the default value or not.

Here is the code including and following the error.

Private Sub Form_Current()
Me.Tenure_Form_Button.Enabled = Me.Frame111 <= 3
End Sub


Private Sub Frame111_AfterUpdate()
Me.Tenure_Form_Button.Enabled = Me.Frame111 <= 3
End Sub

Private Sub Tenure_Form_Button_Click()
On Error GoTo Err_Tenure_Form_Button_Click

Dim stDocName As String
Dim stLinkCriteria As String

stDocName = "Tenure Track Form"

stLinkCriteria = "[ID]=" & Me![ID]
DoCmd.OpenForm stDocName, , , stLinkCriteria

Exit_Tenure_Form_Button_Click:
Exit Sub

Err_Tenure_Form_Button_Click:
MsgBox Err.Description
Resume Exit_Tenure_Form_Button_Click

End Sub

--
Robbin


:

That doesn't seem right. The Default value of a bound control is only
assigned to new records. Anything you enter in the control after the record
has been created will override the default value.

Post the code where the null value error is occuring, please.
--
Dave Hargis, Microsoft Access MVP


:

Thank you, Klatuu. I'm very proud of myself! I actually thought to do that
just after I sent the question, but I'm afraid it doesn't work. Once I type
anything into any field, it activates the default value for the option group.
Problem solved. But by then it's too late.--
Robbin


:

Sounds like the option group is a bound control. Try setting the default
value of the option group to a valid value.
--
Dave Hargis, Microsoft Access MVP


:

Thank you, before I go on, I discovered a problem with the option group
above. When I try to add a new record I get a SQL error - "Invalid Use of
Null". Naturally, it's easily overcome by creating the record, but not very
elegant.

I'll try to compose my other question in a later post.

Thank you again!
--
Robbin


:

Go ahead and post the question. Without some detail, I can't offer a
suggestion.
--
Dave Hargis, Microsoft Access MVP


:

Thank you so much. That worked beautifully. I have another more complex
question about a switch or if statement, but it may be too complicated to
type it all here. Any suggestions?
--
Robbin


:

Use the After Update event of the Option Group

Me.MyButton.Enabled = Me.MyOptionGroup < = 3

If the option group is a bound control, you will also need to put the same
line of code in the form Current event.
--
Dave Hargis, Microsoft Access MVP


:

Hi all,

I hope I'm not duplicating a previous question, but I didn't find it when I
searched.

I have a button on a form that activates a pop-up sub-form. I would like
for the button to remain activated or deactivated (greyed out) based on
option box selections.
Here are the option box selections:
1 Tenured
2 Tenure Approved
3 Tenure Track
4 Non-tenure Track
5 Neither
The option box and the control are on the same form.
I would like the button to be active based on the option box numbers 1, 2,
or 3 and deactive for the rest. If it can't be greyed out, then I guess I
would need a pop-up dialog box telling the user why the button is not active.

Not sure were to set the event or what the code should look like.

Thank you!
 
Ok, I think I have composed it. Please find it under Switch()Clause within
same field, different record.
Thank you!
--
Robbin


Klatuu said:
Great, now for your next question
--
Dave Hargis, Microsoft Access MVP


Robbin said:
Hi Klatuu,

It was the first line -- sorry. But your addition fixed the problem (as you
suspected it would) :-)

Thank you very much!
--
Robbin


Klatuu said:
You did not show which line of code is causing the error. Also, change this
code:
Private Sub Form_Current()
Me.Tenure_Form_Button.Enabled = Me.Frame111 <= 3
End Sub

To
Private Sub Form_Current()
If Not Me.NewRecord Then
Me.Tenure_Form_Button.Enabled = Me.Frame111 <= 3
End If
End Sub


--
Dave Hargis, Microsoft Access MVP


:

Klatuu,

You are right, I misspoke. I meant once I've typed into any OTHER field,
the error is resolved (thus creating a new record). But that is actually the
case whether I use the default value or not.

Here is the code including and following the error.

Private Sub Form_Current()
Me.Tenure_Form_Button.Enabled = Me.Frame111 <= 3
End Sub


Private Sub Frame111_AfterUpdate()
Me.Tenure_Form_Button.Enabled = Me.Frame111 <= 3
End Sub

Private Sub Tenure_Form_Button_Click()
On Error GoTo Err_Tenure_Form_Button_Click

Dim stDocName As String
Dim stLinkCriteria As String

stDocName = "Tenure Track Form"

stLinkCriteria = "[ID]=" & Me![ID]
DoCmd.OpenForm stDocName, , , stLinkCriteria

Exit_Tenure_Form_Button_Click:
Exit Sub

Err_Tenure_Form_Button_Click:
MsgBox Err.Description
Resume Exit_Tenure_Form_Button_Click

End Sub

--
Robbin


:

That doesn't seem right. The Default value of a bound control is only
assigned to new records. Anything you enter in the control after the record
has been created will override the default value.

Post the code where the null value error is occuring, please.
--
Dave Hargis, Microsoft Access MVP


:

Thank you, Klatuu. I'm very proud of myself! I actually thought to do that
just after I sent the question, but I'm afraid it doesn't work. Once I type
anything into any field, it activates the default value for the option group.
Problem solved. But by then it's too late.--
Robbin


:

Sounds like the option group is a bound control. Try setting the default
value of the option group to a valid value.
--
Dave Hargis, Microsoft Access MVP


:

Thank you, before I go on, I discovered a problem with the option group
above. When I try to add a new record I get a SQL error - "Invalid Use of
Null". Naturally, it's easily overcome by creating the record, but not very
elegant.

I'll try to compose my other question in a later post.

Thank you again!
--
Robbin


:

Go ahead and post the question. Without some detail, I can't offer a
suggestion.
--
Dave Hargis, Microsoft Access MVP


:

Thank you so much. That worked beautifully. I have another more complex
question about a switch or if statement, but it may be too complicated to
type it all here. Any suggestions?
--
Robbin


:

Use the After Update event of the Option Group

Me.MyButton.Enabled = Me.MyOptionGroup < = 3

If the option group is a bound control, you will also need to put the same
line of code in the form Current event.
--
Dave Hargis, Microsoft Access MVP


:

Hi all,

I hope I'm not duplicating a previous question, but I didn't find it when I
searched.

I have a button on a form that activates a pop-up sub-form. I would like
for the button to remain activated or deactivated (greyed out) based on
option box selections.
Here are the option box selections:
1 Tenured
2 Tenure Approved
3 Tenure Track
4 Non-tenure Track
5 Neither
The option box and the control are on the same form.
I would like the button to be active based on the option box numbers 1, 2,
or 3 and deactive for the rest. If it can't be greyed out, then I guess I
would need a pop-up dialog box telling the user why the button is not active.

Not sure were to set the event or what the code should look like.

Thank you!
 
Hi Klatuu,

My other question is listed separately under: Subject: Switch() Clause
within the same field, different record.

It's probably not very well phrased.

Please let me know if I need to re-ask it a different way.

Thank you in advance,

--
Robbin


Klatuu said:
Great, now for your next question
--
Dave Hargis, Microsoft Access MVP


Robbin said:
Hi Klatuu,

It was the first line -- sorry. But your addition fixed the problem (as you
suspected it would) :-)

Thank you very much!
--
Robbin


Klatuu said:
You did not show which line of code is causing the error. Also, change this
code:
Private Sub Form_Current()
Me.Tenure_Form_Button.Enabled = Me.Frame111 <= 3
End Sub

To
Private Sub Form_Current()
If Not Me.NewRecord Then
Me.Tenure_Form_Button.Enabled = Me.Frame111 <= 3
End If
End Sub


--
Dave Hargis, Microsoft Access MVP


:

Klatuu,

You are right, I misspoke. I meant once I've typed into any OTHER field,
the error is resolved (thus creating a new record). But that is actually the
case whether I use the default value or not.

Here is the code including and following the error.

Private Sub Form_Current()
Me.Tenure_Form_Button.Enabled = Me.Frame111 <= 3
End Sub


Private Sub Frame111_AfterUpdate()
Me.Tenure_Form_Button.Enabled = Me.Frame111 <= 3
End Sub

Private Sub Tenure_Form_Button_Click()
On Error GoTo Err_Tenure_Form_Button_Click

Dim stDocName As String
Dim stLinkCriteria As String

stDocName = "Tenure Track Form"

stLinkCriteria = "[ID]=" & Me![ID]
DoCmd.OpenForm stDocName, , , stLinkCriteria

Exit_Tenure_Form_Button_Click:
Exit Sub

Err_Tenure_Form_Button_Click:
MsgBox Err.Description
Resume Exit_Tenure_Form_Button_Click

End Sub

--
Robbin


:

That doesn't seem right. The Default value of a bound control is only
assigned to new records. Anything you enter in the control after the record
has been created will override the default value.

Post the code where the null value error is occuring, please.
--
Dave Hargis, Microsoft Access MVP


:

Thank you, Klatuu. I'm very proud of myself! I actually thought to do that
just after I sent the question, but I'm afraid it doesn't work. Once I type
anything into any field, it activates the default value for the option group.
Problem solved. But by then it's too late.--
Robbin


:

Sounds like the option group is a bound control. Try setting the default
value of the option group to a valid value.
--
Dave Hargis, Microsoft Access MVP


:

Thank you, before I go on, I discovered a problem with the option group
above. When I try to add a new record I get a SQL error - "Invalid Use of
Null". Naturally, it's easily overcome by creating the record, but not very
elegant.

I'll try to compose my other question in a later post.

Thank you again!
--
Robbin


:

Go ahead and post the question. Without some detail, I can't offer a
suggestion.
--
Dave Hargis, Microsoft Access MVP


:

Thank you so much. That worked beautifully. I have another more complex
question about a switch or if statement, but it may be too complicated to
type it all here. Any suggestions?
--
Robbin


:

Use the After Update event of the Option Group

Me.MyButton.Enabled = Me.MyOptionGroup < = 3

If the option group is a bound control, you will also need to put the same
line of code in the form Current event.
--
Dave Hargis, Microsoft Access MVP


:

Hi all,

I hope I'm not duplicating a previous question, but I didn't find it when I
searched.

I have a button on a form that activates a pop-up sub-form. I would like
for the button to remain activated or deactivated (greyed out) based on
option box selections.
Here are the option box selections:
1 Tenured
2 Tenure Approved
3 Tenure Track
4 Non-tenure Track
5 Neither
The option box and the control are on the same form.
I would like the button to be active based on the option box numbers 1, 2,
or 3 and deactive for the rest. If it can't be greyed out, then I guess I
would need a pop-up dialog box telling the user why the button is not active.

Not sure were to set the event or what the code should look like.

Thank you!
 
Back
Top