SQL update

  • Thread starter Thread starter 123
  • Start date Start date
1

123

Thank you for your help and answer:
can any one here replace for me insert into to Update in this code
-----------code start------------
Dim FormName
FormName = Screen.ActiveForm.Form.Name
Dim cdl As CommonDlg
Set cdl = New CommonDlg
cdl.CancelError = True
cdl.ShowColor
Screen.ActiveForm.Section(0).BackColor = cdl.color
Dim sql As String
sql = "INSERT INTO tblcolor (" & FormName & ") VALUES (" &
Screen.ActiveForm.Section(0).BackColor & ");"
docmd.runsql sql
----------Code end-----------------------

I want to change INSERT INTO WITH (UPDATE) any one expert in Sql can
help....thank you
 
Do you have only one row in tblColor? If so, this should work:

sql = "UPDATE tblcolor SET " & FormName & " = " &
Screen.ActiveForm.Section(0).BackColor & ";"

--
John Viescas, author
"Microsoft Office Access 2003 Inside Out"
"Running Microsoft Access 2000"
"SQL Queries for Mere Mortals"
http://www.viescas.com/
(Microsoft Access MVP since 1993)
 
Back
Top