Form and SubForm

  • Thread starter Thread starter Jamie
  • Start date Start date
J

Jamie

Hi

I have in my form Commande(Parent) a SubForm Specification
(Child), the two are linked with the ComandeID

I want each time I add a new commande a value with the
specification (Standard) will be added automatically in
my subform. The SpecificationID for Standard is 3

Is it possible and How can I do it

Thanks
 
In the AfterInsert event of the outer form, execute an INSERT SQL command to
add a related row to the subform table and then requery the subform. Your
code might look something like:

Dim strSQL As String
strSQL = "INSERT INTO [SubformTable] (ComandeID, SpecificationID) " & _
"VALUES (" & Me!ComandeID & ", 3)"
CurrentDb.Execute strSQL, dbFailOnError
Me!MySubform.Requery

... you will need to correct the name of "SubformTable" and "MySubform" in
the above sample.

--
John Viescas, author
"Microsoft Office Access 2003 Inside Out"
"Running Microsoft Access 2000"
"SQL Queries for Mere Mortals"
http://www.viescas.com/
(Microsoft Access MVP since 1993)
http://www.deanforamerica.com/site/TR?pg=personal&fr_id=1090&px=1434411
 
Thanks John
-----Original Message-----
In the AfterInsert event of the outer form, execute an INSERT SQL command to
add a related row to the subform table and then requery the subform. Your
code might look something like:

Dim strSQL As String
strSQL = "INSERT INTO [SubformTable] (ComandeID, SpecificationID) " & _
"VALUES (" & Me!ComandeID & ", 3)"
CurrentDb.Execute strSQL, dbFailOnError
Me!MySubform.Requery

... you will need to correct the name of "SubformTable" and "MySubform" in
the above sample.

--
John Viescas, author
"Microsoft Office Access 2003 Inside Out"
"Running Microsoft Access 2000"
"SQL Queries for Mere Mortals"
http://www.viescas.com/
(Microsoft Access MVP since 1993)
http://www.deanforamerica.com/site/TR? pg=personal&fr_id=1090&px=1434411
Hi

I have in my form Commande(Parent) a SubForm Specification
(Child), the two are linked with the ComandeID

I want each time I add a new commande a value with the
specification (Standard) will be added automatically in
my subform. The SpecificationID for Standard is 3

Is it possible and How can I do it

Thanks


.
 
Back
Top