Question : Update Code through VBA

Hi,

I can't seem to understand why my form does not work.  This is the code that I am using to try and update a table from the value found through a form.  I've checked the names and everything matches, field "Work #" is also set as the primary key so it is indexed.  The only thing I found weird is that the "Total Load" field name is automatically capitalized when I type it in.  I'm not sure if this actuallyl makes a difference.  The problem keeps coming up on the rst2.Index = "Work #" line, it basically says that it is a run-time error '3800': 'Work#" is not an index in this table.  Which doesn't make sense to me.  It is the right field and table names.

Dim rst2 As Recordset

Set rst2 = CurrentDb.OpenRecordset("Work Order Info")

rst2.Index = "Work #"
rst2.Seek "=", txtWorkNum

rst2.Edit

rst2![TOTAL LOAD] = txtTotalLoadWD

rst2.Update

Answer : Update Code through VBA

If you set Work # as your primary key and didn't rename your index, Access automatically named it "PrimaryKey" so try :
rst2.Index = "PrimaryKey"
Random Solutions  
 
programming4us programming4us