Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations IamaSherpa on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

sub form question

Status
Not open for further replies.

faxof

Programmer
Dec 5, 2001
272
GB
Hi

I have a form called Project.
It has two subforms called Questions and Answers.

On the Answers subform I want to hide answerTextBox1 if questionBox1 (on the Questions subform) is blank.

any ideas?

cheers Fax
 
You may try something like this in the Current event procedure of Answers:
Me!answerTextBox1.Visible = (Trim(Forms!Project!Questions.Form!questionBox1 & "") <> "")

Hope This Helps, PH.
Want to get great answers to your Tek-Tips questions? Have a look at FAQ219-2884 or FAQ181-2886
 
thanks for that

but it says it cant find the field Questions. But Questions is a form not a field.

i'm slightly confused now :(

fax
 
Hi, Fax,

In the OnCurrent event of the Answers subform, something like this:
Code:
Me![answerTextBox1].Visible = Not IsNull(Me.Parent![[red]Name of Questions subform control[/red]].Form![questionBox1])
Then you'll need a method for turning the visibility back on once data is entered in questionBox1 - AfterUpdate event of questionBox1 should work well for this:
Code:
Me.Parent![[red]Name of Answers subform control[/red]].Form![answerTextBox1].Visible = Not IsNull(Me![questionBox1])

Note the text in red above: a common point of confusion when referencing subforms is that often the name of the subform control (i.e. the control that contains the subform) is not the same as the name of the subform itself (i.e. the name of the subform as it would appear in the database window). You must use the name of the subform control.

HTH, let us know how it goes.

Ken S.
 
Have a look here:

You may also play with the expression builder (loaded forms) to discover the correct syntax.

Hope This Helps, PH.
Want to get great answers to your Tek-Tips questions? Have a look at FAQ219-2884 or FAQ181-2886
 
thanks again - i was using the name of the form rather than the form control. good tip.

however, now i get the following message:
"You entered an expression that has an invalid reference to the property Form/Report"

i tried both Ken and PH's

i wouldnt have thought referring to a siblisg (is that the correct term) form would be so difficult.

cheers
fax
 
although, saying that. when i click end on the message and the form opens. it is working. it hides when there is no question and shows when there is a quiestion.

so thanks very much for that.

but how do i get rid of the error message?

cheers
fax
 
You have which code in which event procedure ?

Hope This Helps, PH.
Want to get great answers to your Tek-Tips questions? Have a look at FAQ219-2884 or FAQ181-2886
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top