using sql to edit a value in a table

  • Thread starter OTWarrior via AccessMonster.com
  • Start date
O

OTWarrior via AccessMonster.com

I need to add data to a table that is not the source of the currently active
form, and I need to use a reference number to select the correct row, I know
of this from another post on MS's forum:

INSERT INTO TableName(Field2, Field3) VALUES (12345,def)

Field1 (column A) will be blank
Field2 = me.bookingID
Field3 = me.txtField


In my example, I would need to select the row via Field2, and add a value
into field3.

I know my code is wrong, I am just getting used to using sql, and need some
help with the next stage.

Thanks in advance
 
G

Graham R Seach

Dim sSQL As String

sSQL = "INSERT INTO TableName(Field2, Field3) " & _
"VALUES (" & Me.bookingID & ",""" & Me.txtField & """)"
CurrentDb.Execute sSQL, dbFailOnError

In the above code, Me.bookingID and Me.txtField will be the currently
selected row.

Regards,
Graham R Seach
Microsoft Access MVP
Sydney, Australia
 

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