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 Chriss Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Docmd.RunSQL "Insert... Into A Bound Field In A Table

Status
Not open for further replies.

dominicdunmow

Technical User
Joined
Jul 28, 2004
Messages
125
Location
CA

I have a subform containing the following fields as textboxes:

ID Revenue Term Yr1 Yr2 Yr3 Yr4 Yr5 Yr6

Users are required to fill in the revenue textbox, then split this by the contract term and fill in the annual revenue values.

To help the users I would like to add a button to the subform that will divide the revenue by the term and automatically add this value to each year of the contract.

I've tried using the Docmd.RunSQL "Insert into... method, but this keeps giving me a syntax error. I also wonder whether there is likely to be other problems as the fields in the table that I'm trying to automatically update with the button are bound to the text fields in the sub form.

Can anybody advise on this please.

Thanks
 

I've used...

DoCmd.RunSQL "INSERT INTO [Revenue_Profile_Table] ([Q1]), VALUES ([1 Q]);"

I probably need a "where" line added to ensure the code adds the values to the correct record, but I'm unsure of the exact "where" line.
 
The easiest way to do this is to create the query in a design grid mode, select view sql and then copy and paste the sql statement. unfortunately you will have to do some tweaking after pasting. Lines will be broken and some of the syntax will probably need to have the quotations changed. Your question regarding the "where" though should be answered. SQL is SELECT, FROM, WHERE. gl
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top