Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations TouchToneTommy on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Update query syntax issue in VB on command click 2

Status
Not open for further replies.

MrMode

Technical User
Aug 28, 2003
195
GB
I have an unbound form with a listbox and text box.

After selecting a item from the listbox the value pushed into a text box.

If required, the text box can be edited and command button pushed.

I want the record to be updated with the edited text in the textbox. The code below currently shows both variables are being captured, but it is giving me a Run-Time error 3075. I am guessing my syntax is wrong but I cannot figure it out.

Code:
    CurrentDb.Execute "UPDATE tblSection SET tblSection.SectionName = " & "" & Me.Text8 & "" & _
                        " WHERE tblSection.SectionID = " & Me.List6
 
Sometimes computers just drive you crazy with their relentless insistence on accuracy!

Solved the syntax issue, the quotation marks needed to be properly addressed. & "'" & Me.Text8 & "'" &

Code:
  CurrentDb.Execute "UPDATE tblSection SET tblSection.SectionName = " & "'" & Me.Text8 & "'" & _
                        " WHERE tblSection.SectionID = " & Me.List6
 
Code:
CurrentDb.Execute "UPDATE tblSection SET tblSection.SectionName = " & "'" & Me.Text8 & "'" & " WHERE tblSection.SectionID = " & Me.List6
or normally done simpler
Code:
CurrentDb.Execute "UPDATE tblSection SET tblSection.SectionName = '" & Me.Text8 & "' WHERE tblSection.SectionID = " & Me.List6
 
MrMode said:
Sometimes computers just drive you crazy with their relentless insistence on accuracy!

I can’t help but comment on that statement.

Would you rather code in this manner (if the code such like this can be even constructed):
When I do something on that Form, I would like to sort-of kind-of something happen that will give me some information that may or may not be what I want.
:)

Have fun.

---- Andy

A bus station is where a bus stops. A train station is where a train stops. On my desk, I have a work station.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top