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 SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Subform within a subform - data entry

Status
Not open for further replies.

lrumd

Technical User
Sep 5, 2002
25
0
0
US
How do I set a subform to accept data only if its parent subform has data?

Let me explain:

frmPatients
subformAppointments
subfrmOrders

I do not want orders entered in the subfrmOrders UNLESS the user has first created an appointment in the subfrmAppointments.

Thanks

Luis

 
set visible = false on the subform until there is a valid value iin the main form.


Rollie E
 
Ok, visible = false in my subform. Now I can't see the subform. Now I need to make the subform become Visible using code; where should I write the code? In the subform itself? In the parent form? In one of the controls? Remember, the subfrmOrders is itself a subform of the subfrmAppointments (which is a subform of frmPatients)

I would like the subfrmOrders to become visible if there is data in the control subfrmAppointments.ApptDate

I guess I can start playing around with OnGotFocus and OnLostFocus and all that jazz, but last time I had to do this I found myself writting code in many different events for the appearence of the form to be correct (OnGotFocus, OnLostFocus, BeforeUpdate, AfterUpdate, OnClick, Private_Subform_Load, etc)

Is there an easier way to do this?. Is there not an option somewhere that specifies if data data can be entered only if there is data in a particular control of another form?

Thanks

Luis
 
Add the following to the On Current Event of the Main form:

If IsNull([Forms]![subfrmAppointments![ApptDate]) then
Me.subfrmOrders.Visible = False
Else
Me.subfrmorders.Visible = True
End if

This will allow you to add orders the subfrmOrders when you open or move to an Order where a date has been entered, or it will hide the subform if no date has been entered.

Now add the following to the After Update event of the Apptdate

Me.subfrmOrders.Visible = True

This will make the subform visible once a date has been entered.

HTH


"I know what you're t'inkin', ma petite. Dat Gambit... still de suave one, no?"
 

fg,

This will only make it visible when you leave the form and then come back. It had better be keyed to the change of the value which triggers the desired event.

Rollie E
 
Thnks jf, but I still have a problem:

I added the line: Me.subfrmOrders.Visible = True
to the AfterUpdate event of the ApptDate but it doesnt work. I am obviously doing something wrong, syntaxis-wise

The actual subform name is tblOrders (don't ask me why I used that name; should have named it subfrmOrders) but now I am not sure how to refer to it from the parent form; I have tried everything I can imagine, including:

Form_tblOrders Subform
[Form_tblOrders Subform]
tblOrders Subform
[tblOrders Subform]
Form.[Form_tblOrders Subform]
[Form].[Form_tblOrders Subform]
Me.[Form].[Form_tblOrders Subform]
Me![Form]![Form_tblOrders Subform]!

and the list goes on and on...

how do I refer to it so that I can then specify....visible=true ?

I am getting a little frustrated

Thanks


Luis
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top