Help with Update query in VBA - PLEASE

N

nxqviet

Hi all,

I've been using VBA to call out Update queries, but now I have too
many of them, I think it is better to include the sql in VBA so that i
can save some space and make it easier to understand. I tried many
many times, but don't know how. So i'm starting from scrat now.

Her is my update query:

UPDATE xyzTest SET xyzTest.Price = [Forms]![xyzTestFrm]![txPrice]
WHERE (((xyzTest.ID)=2) AND ((xyzTest.SessionID)="Session1"));


xyzTest is my Table, the one I want to update
xyzTestFrm is my Form, where the txPrice and SessionID text fields are
located
I want to have a button that run this SQL without calling an actual
query

I need this really bad and urgently. PLEASE help. Thank you very much
for your help and Time.


V_
 
S

SusanV

You're using double quotes inside your VBA statement - try single quotes
instead. Also, you have to bring the form reference outside the quotes and
concatenate it. Try:

CurrentDB.Execute "UPDATE xyzTest SET xyzTest.Price = " &
[Forms]![xyzTestFrm]![txPrice] & "WHERE (((xyzTest.ID)=2) AND
((xyzTest.SessionID)='Session1'));"
 
N

nxqviet

Thank you so much, It worked !! I think you saved my life heheh =)

thanks SusanV



You're using double quotes inside your VBA statement - try single quotes
instead. Also, you have to bring the form reference outside the quotes and
concatenate it. Try:

CurrentDB.Execute "UPDATE xyzTest SET xyzTest.Price = " &
[Forms]![xyzTestFrm]![txPrice] & "WHERE (((xyzTest.ID)=2) AND
((xyzTest.SessionID)='Session1'));"

--
hth,
SusanV




I've been using VBA to call out Update queries, but now I have too
many of them, I think it is better to include the sql in VBA so that i
can save some space and make it easier to understand. I tried many
many times, but don't know how. So i'm starting from scrat now.
Her is my update query:
UPDATE xyzTest SET xyzTest.Price = [Forms]![xyzTestFrm]![txPrice]
WHERE (((xyzTest.ID)=2) AND ((xyzTest.SessionID)="Session1"));
xyzTest is my Table, the one I want to update
xyzTestFrm is my Form, where the txPrice and SessionID text fields are
located
I want to have a button that run this SQL without calling an actual
query
I need this really bad and urgently. PLEASE help. Thank you very much
for your help and Time.
V_- Hide quoted text -

- Show quoted text -
 
S

SusanV

Glad to help any time

;-D

nxqviet said:
Thank you so much, It worked !! I think you saved my life heheh =)

thanks SusanV



You're using double quotes inside your VBA statement - try single quotes
instead. Also, you have to bring the form reference outside the quotes
and
concatenate it. Try:

CurrentDB.Execute "UPDATE xyzTest SET xyzTest.Price = " &
[Forms]![xyzTestFrm]![txPrice] & "WHERE (((xyzTest.ID)=2) AND
((xyzTest.SessionID)='Session1'));"

--
hth,
SusanV




I've been using VBA to call out Update queries, but now I have too
many of them, I think it is better to include the sql in VBA so that i
can save some space and make it easier to understand. I tried many
many times, but don't know how. So i'm starting from scrat now.
Her is my update query:
UPDATE xyzTest SET xyzTest.Price = [Forms]![xyzTestFrm]![txPrice]
WHERE (((xyzTest.ID)=2) AND ((xyzTest.SessionID)="Session1"));
xyzTest is my Table, the one I want to update
xyzTestFrm is my Form, where the txPrice and SessionID text fields are
located
I want to have a button that run this SQL without calling an actual
query
I need this really bad and urgently. PLEASE help. Thank you very much
for your help and Time.
V_- Hide quoted text -

- Show quoted text -
 
Top