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 bkrike on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Table not updating

Status
Not open for further replies.

Stretchy

Programmer
Mar 26, 2002
87
GB
I'm using the following code to update a table through a recordset. Can anyone see anything wrong with it because its not working
__________________________________

Private Sub Add_Click()

Dim rst As ADODB.Recordset
Dim cnn As ADODB.Connection

Set rst = New ADODB.Recordset
Set cnn = CurrentProject.Connection

rst.Open "Select * from tbl_target", cnn, adOpenDynamic, adLockOptimistic
rst.AddNew
rst.Fields("Date") = Me.TarDate
rst.Fields("Department") = Me.dept
rst.Fields("Division") = Me.Division
rst.Fields("Section") = Me.Section
rst.Fields("Target") = Me.AdTarget
rst.Update
rst.Close

Me.Refresh

End Sub
__________________________

thx for any help _______________
Stretchy
 
THx but this hasnt worked. Is there anotyher method other than recordsets that i can use to update the table? _______________
Stretchy
 
Yes there is a way

You can also update it with SQL code

Docmd.RunSQL("UPDATE from
set COLUMNS = VALUE, COLUMNS = VALUE WHERE [CONDITION];")

Try this one to update table

Ciao
Vince
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top