Wrox Programmer Forums
|
Access VBA Discuss using VBA for Access programming.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the Access VBA section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old May 26th, 2005, 04:19 PM
Registered User
 
Join Date: May 2005
Posts: 6
Thanks: 0
Thanked 0 Times in 0 Posts
Default Report to Table Update

I have another question.

I have a report in which i calculate a running sum. I want to be able to copy that into a Table. The Report will only result in one line always. I have a "Temp" Global Variable setup which saves it.

On a form i can just use Tcost.value = temp and it updates it, but it does not work in the form. Since i save it in a global variable i can use it anywhere.

What would be the best way to insert that into the table? I am thinking maybe and SQL statment?

~Daniel

 
Old May 27th, 2005, 09:04 AM
Registered User
 
Join Date: May 2005
Posts: 6
Thanks: 0
Thanked 0 Times in 0 Posts
Default

I guess i'm looking for something like this:

strsql = "Update assemblies set tcost = temp Where Parentid = myvalue"
      CurrentDb.Execute strsql, dbFailOnError

where assemblies is my table and tcost is the field in the table and temp is a global variable i want to assign tcost to and parentid is a field in the table and myvalue is another varible which i am comparing parentid to. instead of my value i could use rst.Fields("Parentid").Value to get the right answer

I get an error when trying to run it

"Run-time error '3061':

To few paramters. expected 2.

Hope u can help i'm guessing i'm just using wrong syntax

 
Old May 27th, 2005, 10:45 AM
Registered User
 
Join Date: May 2005
Posts: 6
Thanks: 0
Thanked 0 Times in 0 Posts
Default

I got my answer, thanks though the correct way is:

strsql = "Update assemblies set tcost = " & temp & " Where Parentid = '" & myvalue & "'"
CurrentDb.Execute strsql, dbFailOnError

where temp is a double and myvalue is a text






Similar Threads
Thread Thread Starter Forum Replies Last Post
update table from another db table timbal25 SQL Server 2005 3 January 19th, 2008 06:47 AM
Update one table to another table using DTS in SQL Printmaker SQL Language 0 July 24th, 2007 07:17 AM
How to Update one table with other table data? ramk_1978 SQL Language 2 May 26th, 2006 12:51 AM
update table with an ID Num from different table scoobie PHP How-To 12 January 25th, 2005 12:28 PM
Update parent table with the sum of child table gbrown SQL Language 2 November 9th, 2004 07:53 AM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.