Cant this be done ??

border20

Registered User.
Local time
Today, 14:31
Joined
Jan 8, 2003
Messages
92
I want to do populate a certain field of a blank table with part of another table (for exportation)

What i thought about goes something like this but i doesn'work,,, dont know if it even possible !

Dim SQLstr As String
SQLstr = "Select [number 1] from tablename where [critere 1] = 'c1';"
DoCmd.RunSQL "UPDATE buffer SET [numero 1] = SQLstr;"

I dont know if i can put a SQL statement inside another like this... if this can be done ? what is the correct syntax? if not, how could i achieve my goal ?
 
border20,

Dim SQLstr As String

SQLstr = "Select [number 1] from tablename where [critere 1] = 'c1';"
DoCmd.RunSQL "UPDATE buffer SET [numero 1] = " & _
SQLstr & ";"

Wayne
 
hummm

weird.. i get an error on the SQL string.... says sintax error on "Select [number 1] from tablename"

the table and field name are correct...
 
border20,

I only looked at your initial post for syntax.

I did a test example and got "Operation requires an
updateable query".

I remember using that same syntax with ORACLE's SQL.

A work-around could be to use either an update query,
or if it must be code you could use a DLookup to get the
value and then use this syntax:


DoCmd.RunSQL "UPDATE buffer SET [numero 1] = " & _
DLookUpResult & ";"

That should work.

Wayne
 
ok

but i have to affect the dlookup to a variable... it wont let me run this command alone

DLookup("[number 1]", "Tablename", "[critere 1] = 'c1' ")

so i dit this :

Dim varx As Variant
varx = DLookup("[number 1]", "Tablename", "[critere 1] = 'c1'")
DoCmd.RunSQL "UPDATE buffer SET [numero 1] = " & _
varx & ";"

but instead of writing the correct numbers... it asked me for parameter "323,3" wich is the value of the first reccord of [number 1]in Tablename.

Whatever number I put as parameter, it writes this number throughout the buffer table...
 

Users who are viewing this thread

Back
Top Bottom