report to table

T

TheGerman

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 report. 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
 
T

TheGerman

I already wrote an automatic update function, so that is no problem. I put
way to much time into this already to change it. I am almost done. All i
ned now is to store these values in the able and i'm set!

~Daniel
 
T

TheGerman

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
 
F

fredg

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

Assuming Temp and ParentID are Number datatypes.

strsql = "Update assemblies set tcost = " & temp & " Where Parentid =
" & myvalue & ";"
 
T

TheGerman

Thanx, it seems to almost work. temp is set as a double because i need the
decimals, but myvalue is a string

values for myvalue may include:

001551
c12459
2525dgb

how would i accomidate that?
 
T

TheGerman

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

i used that and it worked great. Thank you very much for your help!
 
Top