Problem with SetValue

  • Thread starter Thread starter CSDunn
  • Start date Start date
C

CSDunn

Hello,
I have a check box control on a subform that I want to set 'Enabled' to 'No'
if a bound text box on the subform contains NULL records, and set the check
box control 'Enabled' property to 'Yes' if the text box Is Not NULL. The
'Yes' or 'No' state of the check box needs to be obvious to the user after
the main form is opened.

I have a macro set up in an Access 2000 project for this, but whether the
text box in the subform is NULL or Is Not NULL, the check box control's
'Enabled' property always appears to be set to 'No'. That is, the check box
control is never enabled.

In the macro called 'Main.CountApproved', the first condition to turn the
'WOApproved' check box off is as follows. The 'WorkOrderID' text box control
that is being evaluated is actually in a subform that is within another
subform:
[Forms]![frmSite]![tblWorkOrder
Subform].[Form]![frmApproveAccess].[Form]![WorkOrderID] Is Null

The 'SetValue' action to occur on the 'Enabled' property of the checkbox
called 'WOapproved' in the 'frmApproveAccess' subform if the above statement
is true is as follows:
[Forms]![frmSite]![tblWorkOrder
Subform].[Form]![frmApproveAccess].[Form]![WOapproved].[Enabled] = No

The second condition in the macro is supposed to turn the checkbox on given
the following condition for the textbox:
[Forms]![frmSite]![tblWorkOrder
Subform].[Form]![frmApproveAccess].[Form]![WorkOrderID] Is Not Null

The 'SetValue' action for the 'Enabled' property of the checkbox, given that
the above statement is true, should be as follows:
[Forms]![frmSite]![tblWorkOrder
Subform].[Form]![frmApproveAccess].[Form]![WOapproved].[Enabled]=Yes

I have assigned the macro 'Main.CountApproved' to the 'On Current' event of
the main form, 'frmSite'. 'WorkOrderID' in the the 'frmApproveAccess'
subform is visible in order to eliminate a problem I was having with this
field being hidden. When 'WorkOrderID' was hidden, I would recieve a message
when opening the main form, 'frmSite' that said, "You can't disable a
control while it has the focus".

The 'Name' and 'Control Source' properties match for each control. There are
no error messages. Its just that the check box control is never enabled,
whether 'WorkOrderID' is null or not.

What do I need to do so that the checkbox will be enabled when 'WorkOrderID'
Is Not Null, and will be disabled when 'WorkOrderID' Is Null?

Thanks for your help!

CSDunn
 
Big Thanks!
CSDunn

John Viescas said:
You need to put the macro in the Current event of the subform. Also, you
don't need the second test. Add a line after the first test, put three dots
in the Condition column, and enter a StopMacro action. Follow that with the
SetValue Enabled = True. (Use True and False instead of Yes and No.)

--
John Viescas, author
"Microsoft Office Access 2003 Inside Out" (coming soon)
"Running Microsoft Access 2000"
"SQL Queries for Mere Mortals"
http://www.viescas.com/
(Microsoft Access MVP since 1993)
CSDunn said:
Hello,
I have a check box control on a subform that I want to set 'Enabled' to 'No'
if a bound text box on the subform contains NULL records, and set the check
box control 'Enabled' property to 'Yes' if the text box Is Not NULL. The
'Yes' or 'No' state of the check box needs to be obvious to the user after
the main form is opened.

I have a macro set up in an Access 2000 project for this, but whether the
text box in the subform is NULL or Is Not NULL, the check box control's
'Enabled' property always appears to be set to 'No'. That is, the check box
control is never enabled.

In the macro called 'Main.CountApproved', the first condition to turn the
'WOApproved' check box off is as follows. The 'WorkOrderID' text box control
that is being evaluated is actually in a subform that is within another
subform:
[Forms]![frmSite]![tblWorkOrder
Subform].[Form]![frmApproveAccess].[Form]![WorkOrderID] Is Null

The 'SetValue' action to occur on the 'Enabled' property of the checkbox
called 'WOapproved' in the 'frmApproveAccess' subform if the above statement
is true is as follows:
[Forms]![frmSite]![tblWorkOrder
Subform].[Form]![frmApproveAccess].[Form]![WOapproved].[Enabled] = No

The second condition in the macro is supposed to turn the checkbox on given
the following condition for the textbox:
[Forms]![frmSite]![tblWorkOrder
Subform].[Form]![frmApproveAccess].[Form]![WorkOrderID] Is Not Null

The 'SetValue' action for the 'Enabled' property of the checkbox, given that
the above statement is true, should be as follows:
[Forms]![frmSite]![tblWorkOrder
Subform].[Form]![frmApproveAccess].[Form]![WOapproved].[Enabled]=Yes

I have assigned the macro 'Main.CountApproved' to the 'On Current' event of
the main form, 'frmSite'. 'WorkOrderID' in the the 'frmApproveAccess'
subform is visible in order to eliminate a problem I was having with this
field being hidden. When 'WorkOrderID' was hidden, I would recieve a message
when opening the main form, 'frmSite' that said, "You can't disable a
control while it has the focus".

The 'Name' and 'Control Source' properties match for each control. There are
no error messages. Its just that the check box control is never enabled,
whether 'WorkOrderID' is null or not.

What do I need to do so that the checkbox will be enabled when 'WorkOrderID'
Is Not Null, and will be disabled when 'WorkOrderID' Is Null?

Thanks for your help!

CSDunn
 
This would really be much easier in Visual Basic. Change the Current event
property of the subform to [Event Procedure] and click the Build button (the
one with three dots on it). Enter the following in the procedure that
Access builds for you:

Private Sub Form_Current()
If IsNull(Me.WorkOrderID) Then
Me.WOApproved.Enabled = False
Else
Me.WOApproved.Enabled = True
End If
End Sub

--
John Viescas, author
"Microsoft Office Access 2003 Inside Out" (coming soon)
"Running Microsoft Access 2000"
"SQL Queries for Mere Mortals"
http://www.viescas.com/
(Microsoft Access MVP since 1993)
CSDunn said:
Big Thanks!
CSDunn

John Viescas said:
You need to put the macro in the Current event of the subform. Also, you
don't need the second test. Add a line after the first test, put three dots
in the Condition column, and enter a StopMacro action. Follow that with the
SetValue Enabled = True. (Use True and False instead of Yes and No.)

--
John Viescas, author
"Microsoft Office Access 2003 Inside Out" (coming soon)
"Running Microsoft Access 2000"
"SQL Queries for Mere Mortals"
http://www.viescas.com/
(Microsoft Access MVP since 1993)
CSDunn said:
Hello,
I have a check box control on a subform that I want to set 'Enabled'
to
'No'
if a bound text box on the subform contains NULL records, and set the check
box control 'Enabled' property to 'Yes' if the text box Is Not NULL. The
'Yes' or 'No' state of the check box needs to be obvious to the user after
the main form is opened.

I have a macro set up in an Access 2000 project for this, but whether the
text box in the subform is NULL or Is Not NULL, the check box control's
'Enabled' property always appears to be set to 'No'. That is, the
check
box
control is never enabled.

In the macro called 'Main.CountApproved', the first condition to turn the
'WOApproved' check box off is as follows. The 'WorkOrderID' text box control
that is being evaluated is actually in a subform that is within another
subform:
[Forms]![frmSite]![tblWorkOrder
Subform].[Form]![frmApproveAccess].[Form]![WorkOrderID] Is Null

The 'SetValue' action to occur on the 'Enabled' property of the checkbox
called 'WOapproved' in the 'frmApproveAccess' subform if the above statement
is true is as follows:
[Forms]![frmSite]![tblWorkOrder
Subform].[Form]![frmApproveAccess].[Form]![WOapproved].[Enabled] = No

The second condition in the macro is supposed to turn the checkbox on given
the following condition for the textbox:
[Forms]![frmSite]![tblWorkOrder
Subform].[Form]![frmApproveAccess].[Form]![WorkOrderID] Is Not Null

The 'SetValue' action for the 'Enabled' property of the checkbox,
given
that
the above statement is true, should be as follows:
[Forms]![frmSite]![tblWorkOrder
Subform].[Form]![frmApproveAccess].[Form]![WOapproved].[Enabled]=Yes

I have assigned the macro 'Main.CountApproved' to the 'On Current'
event
of
the main form, 'frmSite'. 'WorkOrderID' in the the 'frmApproveAccess'
subform is visible in order to eliminate a problem I was having with this
field being hidden. When 'WorkOrderID' was hidden, I would recieve a message
when opening the main form, 'frmSite' that said, "You can't disable a
control while it has the focus".

The 'Name' and 'Control Source' properties match for each control.
There
are
no error messages. Its just that the check box control is never enabled,
whether 'WorkOrderID' is null or not.

What do I need to do so that the checkbox will be enabled when 'WorkOrderID'
Is Not Null, and will be disabled when 'WorkOrderID' Is Null?

Thanks for your help!

CSDunn
 
Back
Top