Hello,
I'm writing some VBA in Access, part of which is to write to a table. I'm using this:
Set db = CurrentDb
Set rst = db.OpenRecordset("tblParcels")
rst.AddNew
rst!ID = 1
rst!URN = "TEST"
rst.Update
this = rst!URN
MsgBox this
However, when I run the code and then look at the table no update has taken place. I'm not getting any error messages. If I update the table manually and then run the last two lines above to display the value in rst!URN, I do get the right output (I've Dimmed everything earlier in the code).
I think I'm missing out a fundamental step somewhere. For now I've resorted to updating the table using SQL, but this might not be the most efficient way of doing it. Any general advice on the best way to write to a table in VBA would be appreciated.
thanks
jamsta
I'm writing some VBA in Access, part of which is to write to a table. I'm using this:
Set db = CurrentDb
Set rst = db.OpenRecordset("tblParcels")
rst.AddNew
rst!ID = 1
rst!URN = "TEST"
rst.Update
this = rst!URN
MsgBox this
However, when I run the code and then look at the table no update has taken place. I'm not getting any error messages. If I update the table manually and then run the last two lines above to display the value in rst!URN, I do get the right output (I've Dimmed everything earlier in the code).
I think I'm missing out a fundamental step somewhere. For now I've resorted to updating the table using SQL, but this might not be the most efficient way of doing it. Any general advice on the best way to write to a table in VBA would be appreciated.
thanks
jamsta