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 strongm 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

Status
Not open for further replies.

lrumd

Technical User
Sep 5, 2002
25
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
 
What do you mean by "parent subform has data" or "the user has first created an appointment"? Do you mean that any data has been entered in subformAppointments, or do you mean that a record has been saved? If the latter, what methods can the user use to save the record--click a command button, navigate records, select Save Record from a menu?

Also, can subformAppointments browse through existing records? If so, should subfrmOrders allow data entry when an existing record is being viewed?

Rick Sprague
Want the best answers? See faq181-2886
To write a program from scratch, first create the universe. - Paraphrased from Albert Einstein
 
lrumd

You may get errors if tyring to embed a subform within a subform. My suggestion -- use a Tab form

Main form is above the tab form, and used for patients.

On one tab, have appointments. This should be fairly easy. You can use either a continuous or single form.

The second tab is used for orders, and depends on your database design. If your order form includes the patient ID, it should be fairly easy. If it only uses the appointment reference, the solution is more complex. Develop a query to retrieve the patient + appointment + order.

Okay, now your next issue. When you state that a patient needs to have an appointment before they can have an order, more information is required on your database design.

Without getting into too much detail...

tblPatient
patient_id
name
contact_info...

tblAppointment
appoint_id
patient_id
date_time_room ...

For the order, two possibilities...

1) tblOrder
order_id
patient_id
product_id...

or

2) tblOrder
order_id
patient_id
appointment_id
product_id

For the first scenario, you have to add code to on current event and load event for the subform to make it invisible and reset the focus to the patient part of the form....

pseudo code would be

how many appoinments does patient have
if zero then make the order form inisble, etc.

For the second scenario, make the appoinment field not accept nulls and Access will do the work for you.

Good luck
Richard
 
Thanks, Richard.
Never used tabs, looks VERY interesting
Luis
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top