Form and SubForm

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
 
J

John Viescas

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
 
J

JAmie

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


.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top