Updating Access table using DAO

presence76

Board Regular
Joined
May 11, 2004
Messages
76
I am attemtping to update a table in access from a value received from a form. When I run it, I get the following error : run time error 3265 - 'item not found in this collection. Below is the code:

Code:
Dim newmgmtcode As String
Dim dbs As DAO.Database
Dim rst As DAO.Recordset
Set dbs = CurrentDb()

newmgmtcode = Forms![form1]![textmgmtcode].Value                 ' get new mgmt code from screen

Set rst = dbs.OpenRecordset("tblmgmtcodecurrent")
With rst
  .AddNew
  .Fields(1).Value = newmgmtcode
  .Update
End With

I have been searching this site for a while to try to solve this. I know it's something real simple. Any help would be appreciated. Thanks.
 

Excel Facts

Bring active cell back into view
Start at A1 and select to A9999 while writing a formula, you can't see A1 anymore. Press Ctrl+Backspace to bring active cell into view.
Thanks alot for the info. Now, when I execute the form, I get
'invalid use of null' when I assign the value to the variable on this line:


newmgmtcode = Forms![form1]![textmgmtcode].Value

The strange thing about is that I had this problem earlier (before removing value) and I ran thru the debugger once and it worked, then I went out of debug mode, executed the form and got this. I tried to go throught the debugger again this time, and now it does not work either way.

Any ideas would be greatly appreciated.
 
Upvote 0
I removed value from the form assignment lineline and got the same result.

line now looks like this:

newmgmtcode = Forms![form1]![textmgmtcode]
 
Upvote 0
Have you checked that all the names are correct?
 
Upvote 0
Yes, I double checked all that. Again, the strange thing about it is that it did work with the .Value at the end of it. But before I even changed the .value line on the table update, I had a problem with this. I thought maybe I had an odd setting on the textbox definition itself, but I checked all those as well. Is there something wrong with the brackets?
 
Upvote 0

Forum statistics

Threads
1,223,261
Messages
6,171,076
Members
452,377
Latest member
bradfordsam

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top