DoCmd.RunSQL

  • Thread starter Thread starter taccea
  • Start date Start date
T

taccea

Hello,

I sent this message without a subject and I did not see it posting, so I am
resending
with the Subject Line filled, hope I don't mess things up because of this.

==================================================
I am trying to copy data from on table to another with the following code:

Do While Not rsCommonInfo.EOF
a = rsCommonInfo!bonus_id
DoCmd.RunSQL "INSERT INTO ghtCheckDetailTemp SELECT GHTcheckDetail2.*
FROM GHTcheckDetail2 WHERE GHTcheckDetail2.bonus_id = a"

rsCommonInfo.MoveNext
Loop

of course it does not work , I need to find out how to pass the "a" part
to the select statement.
rsCommonInfo and "a" hasvebeen declared correctly. If I put a literal
number instead of "a", it will work but I need to pass the contents of
variable "a".

Please help.

Taccea
 
taccea said:
Hello,

I sent this message without a subject and I did not see it posting,
so I am resending
with the Subject Line filled, hope I don't mess things up because of
this.

==================================================
I am trying to copy data from on table to another with the following
code:

Do While Not rsCommonInfo.EOF
a = rsCommonInfo!bonus_id
DoCmd.RunSQL "INSERT INTO ghtCheckDetailTemp SELECT
GHTcheckDetail2.* FROM GHTcheckDetail2 WHERE
GHTcheckDetail2.bonus_id = a"

rsCommonInfo.MoveNext
Loop

of course it does not work , I need to find out how to pass the "a"
part to the select statement.
rsCommonInfo and "a" hasvebeen declared correctly. If I put a literal
number instead of "a", it will work but I need to pass the contents of
variable "a".

Can I assume that the variable a is a number, and the field bonus_id is
a numeric type? If so, try this:

DoCmd.RunSQL _
"INSERT INTO ghtCheckDetailTemp " & _
"SELECT GHTcheckDetail2.* FROM GHTcheckDetail2 " & _
"WHERE GHTcheckDetail2.bonus_id = " & a
 
YOU KNOW IT, THANKS!

Taccea

Dirk Goldgar said:
Can I assume that the variable a is a number, and the field bonus_id is
a numeric type? If so, try this:

DoCmd.RunSQL _
"INSERT INTO ghtCheckDetailTemp " & _
"SELECT GHTcheckDetail2.* FROM GHTcheckDetail2 " & _
"WHERE GHTcheckDetail2.bonus_id = " & a

--
Dirk Goldgar, MS Access MVP
www.datagnostics.com

(please reply to the newsgroup)
 
Back
Top