Solved How to create a Master Record (Parent Form) when all of its values are okay with the Default Values itself?

prabha_friend

Prabhakaran Karuppaih
Local time
Today, 22:00
Joined
Mar 22, 2009
Messages
944
Just we have to enter data in the Sub-form Only.
 
Today I will fix my multiple user accounts. Sorry for the late comeback on saying this...
 
Of course you can only create that record once...

If such a record COULD exist based ONLY on defaults, it would have no unique identifier (PK) and therefore could never be the ONE side of a ONE:MANY formal relationship, so you could never enter dependent records (child records). There would be nothing on which to depend.
 
Of course you can only create that record once...

If such a record COULD exist based ONLY on defaults, it would have no unique identifier (PK) and therefore could never be the ONE side of a ONE:MANY formal relationship, so you could never enter dependent records (child records). There would be nothing on which to depend.
There is a Primary Key (AutoNumber)
 
Table1: Bills
Bill_ID(Auto Number); Bill_DateVal(Date/Time)
Table2: Sales
Sales_ID;Bill_ID;Item;Rate;Qty;Price
 
Of course you can only create that record once...

If such a record COULD exist based ONLY on defaults, it would have no unique identifier (PK) and therefore could never be the ONE side of a ONE:MANY formal relationship, so you could never enter dependent records (child records). There would be nothing on which to depend.
There is a Primary Key in the Parent table: Bill_ID (AutoNumber)
 
You have actually asked a question for which I'm a bit stumped and had to think for a while. Seeing the record contents, I'm not sure that this case actually requires a parent record if that is all that is in the parent record you showed us. It might actually be OVER-normalized. Unless there is something else to exist in that Bill_ID table, like perhaps a customer ID, you have no reason to have a parent/child relationship. That might be part of why you got no other replies. Your scenario is confusing.

Now if you had a customer ID to go with the bill, it would be trivial to do this. I suppose you could write a little subroutine on the form. But... assuming you really meant you wanted it with ALL DEFAULTS and no externally imposed values, it might look like this.

Code:
Public Function CreateBillID() As LONG
DIM BIDRS as DAO.Recordset
SET BIDRS = CurrentDB.OpenRecordset( "BillID" )      'default is table-type recordset
BIDRS.ADDNEW
'    the autonumber and default for the date field will kick in here...
BIDRS.UPDATE
CreateBillID = BIDRS!<the name of the PK field that is autonumbered goes here>
BIDRS.CLOSE
SET BIDRS = NOTHING
End Sub

This does NO error checking, but this or something like it would create the parent record with all default values and tell you the new record's ID.
 

Users who are viewing this thread

Back
Top Bottom