Default List

naungsai

Abecedarian
Local time
Today, 17:46
Joined
Sep 8, 2008
Messages
123
Dear Friends :p

I have created a form with subform. I want to put (let's say) 3 default records into the subform whenever I start a new record in main form.

For Example; when I enter a new record in main form, the following records will wainting me to modify in the subform.

Description Amount
Beer 1
Wine 1
Wisky 1

After that, I just need to modify the Amount Column.

Please help me. I think it should be written in VB.
 
Look at "DemoDefaultRecA2000.mdb" (attachment, zip).
Look at tables, forms (VBA), relationships, Query1App.
Open Form1 and try to add a new record.
 

Attachments

Well, with a bit of VBA it should be quite easy

Say if you have main form with its subform (linked together offcourse). I assume that the subform is for a Child table. On the After Update event of the suitable text box on the main form you will put.

'Save Master Record
DoCmd.RunCommand acCmdSaveRecord

'Create Child Records
DoCmd.RunSQL "Insert Into TblChild (LinkID, Desc) Values (" & me.LinkID & ", 'Beer');"
DoCmd.RunSQL "Insert Into TblChild (LinkID, Desc) Values (" & me.LinkID & ", 'Wine');"
DoCmd.RunSQL "Insert Into TblChild (LinkID, Desc) Values (" & me.LinkID & ", 'Wisky');"

'Refresh Sub form
Me.MySubForm.Requery

'Move Focus to Subform
Me.MySubForm.setFocus

Hope that this will start you in right direction. I have just written the code without checking it for commas or anything so please correct something if missing.
 
Look at "DemoDefaultRecA2000.mdb" (attachment, zip).
Look at tables, forms (VBA), relationships, Query1App.
Open Form1 and try to add a new record.

Fabulous
It works beautifully. Thank you.:)
 
Hello agif, naungsai

It is not a good idea "After update", but "Affter Insert".
 

Users who are viewing this thread

Back
Top Bottom