SQL update statement using form data as field name
im trying to write a SQL statement that will update a column in my access database based on a selection chosen from a form. the select box in the form is called STEP. the values range from A_DATE to U_DATE. there also two textboxes, one called "CONNUM" and one called "ENTDATE". the database has columns called "CON_NUM" and others, ranging from A_DATE to U_DATE. an example: the user chooses STEP = A_DATE, then enters 3002 in CONNUM, and 12/23/2004 in ENTDATE. when they submit, the database should update column A_DATE with 12/23/2004 WHERE CON_NUM=3002. im kinda familar with SQL but just can not get this to work. here's my code so far:
if i replace '"& putSTEP &"' with A_DATE, it works. however, if i did it that way, i'd have to write IF and SQL statements for each STEP from A_DATE to U_DATE. any ideas?
sql="UPDATE CONTRACTS SET '"& putSTEP &"' = '" & putENTDATE & "' WHERE CON_NUM = '"& putCONNUM & "'"
thanks in advance for the help.
when you echo it, the statement looks correct? do you need the single quotes around the field in Access??
you're exactly right, it works without the single quotes around the field :
thanks for the help!
sql="UPDATE CONTRACTS SET "& putSTEP &" = '" & putENTDATE & "' WHERE CON_NUM = '"& putCONNUM & "'"
Users Browsing this Thread
There are currently 1 users browsing this thread. (0 members and 1 guests)