Hide text box

D

DRMOB

I am trying to hide a text box on a subform if a check box is = to false. I
am close in doing so, but not there yet. This is what I have
In the AfterUpdate property of the check box I have the following:

Private Sub RevisedGrant_AfterUpdate()
If Me![RevisedGrant] = True Then
If MsgBox("Are you sure you want to revise this grant?", vbYesNo) =
vbNo Then
Me![RevisedGrant] = False
MsgBox "Grant will NOT be revised", vbOKOnly

Forms![DataEntryFrm]![ItemSubFrm]![Total$ofItemsRequestedSubfrm].Form![Revised Total Approved].Visible = False
End If
Else
If MsgBox("Are you sure you don't want to revise this grant?",
vbYesNo) = vbYes Then
Me![RevisedGrant] = False
MsgBox "You will not be revising the grant.", vbOKOnly

Else
Me![RevisedGrant] = True

Forms![DataEntryFrm]![ItemSubFrm]![Total$ofItemsRequestedSubfrm].Form![Revised Total Approved].Visible = True
End If
End If

In the On Current Property of the Subform (which is where the text box is I
am trying to hide) I have the following code:
Private Sub Form_Current()

If Forms![DataEntryFrm].Form![RevisedGrant] = True Then
Me.Revised_Total_Approved.Visible = True
Else
Me.Revised_Total_Approved.Visible = False
End If
End Sub

If I open the form and move from record to record, the text box is hidden if
the check box is false and shows if it is true. However, if I change it from
False to True, the text box does not appear until I move off the record and
back again. What am I missing? Please help, I've been on this for way too
long. Thanks
 
K

Klatuu

The problem is that when referring to a sub form, you have to specify the
form propertry of the subform control.

Forms![DataEntryFrm]![ItemSubFrm].Form![Total$ofItemsRequestedSubfrm].Form![Revised Total Approved].Visible = False

Not that ItemSubFrm should be the name of the subform control on your main
form, not the name of the form being used as a sub form.

This is a confusing area for most folks. How it works is you create a
subform control on your form. That control has a property named Source
Object. The Source Object property contains the name of the form to be used
as a subform. So it is like dealing with any other form control. You
identify the name of the control, then reference the Form property which as
the name used to point to the Source Object property. Then once you
establish the control and the form property, you refer to the controls on the
form.

Forms!MainFormName!SubFormControlName.Form!ControlName
 

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