SQL UPDATE statement HELP

  • Thread starter RedHeadedMonster via AccessMonster.com
  • Start date
R

RedHeadedMonster via AccessMonster.com

I have the following statement in my code:

Dim sqlUpdateOracleQty As String

Dim myswID As Long
myswID = Me![swID]

DoCmd.SetWarnings (0)

sqlUpdateOracleQty = "UPDATE MAINsw SET MAINsw.[swQtyOnHand] = -1 WHERE
MAINsw.[swID] = myswID "

DoCmd.RunSQL sqlUpdateOracleQty

When the code runs I get the following:

A parameter box pops up and asks for the value of myswID.

I've changed a hundered things (or it feels like it) and I still get the same
thing.
WTH am I doing wrong.

Thanx!
RHM
 
R

RonaldoOneNil

myswID is a value from a textbox on your form so to get the value it needs to
be outside of the quoted string
(This also assumes that the value is numeric)

sqlUpdateOracleQty = "UPDATE MAINsw SET MAINsw.[swQtyOnHand] = -1 WHERE
MAINsw.[swID] = " & myswID
 
S

Sylvain Lafontaine

You must use the value of myswID to build your update string:

sqlUpdateOracleQty = "UPDATE MAINsw SET MAINsw.[swQtyOnHand] = -1 WHERE
MAINsw.[swID] = " & myswID

In the case of a string value, you must not forget to enclose its value
between quote or double quote or with whatever is relevant on Oracle. Don't
forget to double any embedded delimiter (by using the Replace function) if
the delimiter that you'll use can also be part of the string value itself.

--
Sylvain Lafontaine, ing.
MVP - Windows Live Platform
Email: sylvain2009 sylvainlafontaine com (fill the blanks, no spam please)
Independent consultant and remote programming for Access and SQL-Server
(French)
 
R

RedHeadedMonster via AccessMonster.com

Freaking " marks. Its always so simple. It now works perfectly.
Thanx to both of you for your help.
RHM
myswID is a value from a textbox on your form so to get the value it needs to
be outside of the quoted string
(This also assumes that the value is numeric)

sqlUpdateOracleQty = "UPDATE MAINsw SET MAINsw.[swQtyOnHand] = -1 WHERE
MAINsw.[swID] = " & myswID
I have the following statement in my code:
[quoted text clipped - 20 lines]
Thanx!
RHM
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top