Main form default value from subform

mad-q

Registered User.
Local time
Today, 11:27
Joined
Feb 14, 2010
Messages
61
Hello,

I have done a search and can't find an answer to this.

I have a main form and when you start to fill in the fields it will fill the default values for the others. If I start filling in the subform before entering in the main form the data is lost. Is there a way in which when entering data in the subform it will pick the default values in the main form?

Thanks
Iain
 
You seem to misunderstand what a form and subform do and how they are related. The main form should be based on the table which would be considered the parent record of the record that would appear in the table the subform is based upon.

So, for example, if I have a table structure of this:

tblOrders
OrderID - Autonumber (PK)
OrderDate - Date/Time
CustomerID - Long Integer (FK)

tblOrderDetails
OrderDetailID - Autonumber (PK)
OrderID - Long Integer (FK)
ProductID - Long Integer (FK)
Price - Currency
Qty - Integer


So my main form would be based on the Orders Table. Then the subform would be based on the Order Details table. And the two forms, parent form and subform, are linked with their Master/Child links being set to OrderID. I need to fill in the Order header information first (the main form) which then I can THEN, and ONLY THEN, start to fill in the subform with the order details.

So, what it sounds like is that you have your tables but no Referential Integrity set up so that it will actually let you enter what are known as ORPHAN RECORDS. If you start to fill in the subform first then there is nothing to associate with for the parent record and it just lets you. But then you go to fill out the parent form and if you then returned and started a new subform record, that would probably show up with the parent record when you came back.

You need to set your relationships and referential integrity in the Relationships area of the database.
 
Bob

Thank you so much for that but I already have the referential integrity ticked and it all works fine apart from when someone forgets to create a parent record and just starts entering info within the subform and then we get an orphan record.

What I would like is if it would either create a parent record if none has been entered or not allow child records to be created without a parent.

Many Thanks
Iain
 

Users who are viewing this thread

Back
Top Bottom