sql with textbox

thescottsman

Registered User.
Local time
Today, 14:36
Joined
Sep 18, 2014
Messages
42
Hi all

I have an sql which is used to update a table

I am wanting to update the column1 with the value of an unbound texbox on a form

can anyone help?
 
When you say >>>I am wanting to update the column1<<< do you mean one record in that column, or all the records in that column?
 
Hi

One record that is specified in another column
 
This is the code I currently have. It is not allowing me to update the second column. When I tae this line out it works how it is supposed to

Dim ContractSQl As String
ContractSQl = "UPDATE tblContracts " & _
"SET Order='" & Me.conOrder.Value & "' " & _
"SET PO='" & Me.conPO.Value & "' " & _
"WHERE ContractNumber='" & Me.conContractNumber.Value & "' "
DoCmd.SetWarnings False
DoCmd.RunSQL ContractSQl
 
I don't think the SQL string you've constructed uses the correct syntax. You have two occurences of 'SET', where I think the second one should just be a comma.

Try this

Dim ContractSQl As String
ContractSQl = "UPDATE tblContracts " & _
"SET Order='" & Me.conOrder.Value & "' " & _
", PO='" & Me.conPO.Value & "' " & _
"WHERE ContractNumber='" & Me.conContractNumber.Value & "' "
DoCmd.SetWarnings False
DoCmd.RunSQL ContractSQl

I find it useful when constructing SQL statements to debug.print the variable that you're using to store them before you run them. If you then copy the resulting SQL from the Immediate window to a query SQL view and try to run it or switch to design view then you should get no errors in most cases.
 

Users who are viewing this thread

Back
Top Bottom