Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Getting Data from a Subform into a Table

Status
Not open for further replies.

CopperWire

Technical User
Jun 25, 2003
47
0
0
US
I've got the main form, which is populated via a query. The subform that's on the main form is based on the table that I want to populate. The subform contains records that users can change (just certain ones) and it also contains all the records in the table. The records the user can not change are hidden from the user, but I want those hidden fields to be updated from the main form query. I set the default for these fields as the value in the main form, but I don't know how to get the default values into the table. I read the thread 702-1338332, but the default values change based on the record selected in the main form, so my problem is not totally the same.

I know there must be an easier way...please help!
 
After reading some other posts, I came up with the code below, but I'm getting a syntax error. Can anyone help.

CurrentDb.Execute ("INSERT INTO Refund Customers(ChCSSPremiseNumber, Op Unit) VALUES (" & ChCSSPremiseNumber & ", '" & Forms!RefundableForm![Op Unit] & ");")

The Forms!RefundableForm![op Unit]refers to the main form that the sub form is on. I want the value from this field to be input into the table Refund Customers.
 
CurrentDb.Execute ("INSERT INTO Refund Customers(ChCSSPremiseNumber, Op Unit) VALUES (" & ChCSSPremiseNumber & ", '" & Forms!RefundableForm![Op Unit] & "[!]'[/!]);")

Hope This Helps, PH.
Want to get great answers to your Tek-Tips questions? Have a look at FAQ219-2884 or FAQ181-2886
 
Thank you PHV. I still get a syntax error. Can you use this command to insert records into a table from a form?

What I'm trying to do is populate the OP Unit field in the subform with the parent form, which is based off a query in order to save the data from the query and the data from the sub form in one record.

 
CurrentDb.Execute ("INSERT INTO [!][[/!]Refund Customers[!]][/!] (ChCSSPremiseNumber, [!][[/!]Op Unit[!]][/!]) VALUES (" & ChCSSPremiseNumber & ", '" & Forms!RefundableForm![Op Unit] & "[!]'[/!]);")

Hope This Helps, PH.
Want to get great answers to your Tek-Tips questions? Have a look at FAQ219-2884 or FAQ181-2886
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top