Villarreal68
Registered User.
- Local time
- Today, 10:23
- Joined
- Feb 15, 2007
- Messages
- 133
Newbie! 
While creating my "First Database" it being a OnLoan/inventory database I needed to create a process to remove "OnLoan" Items from the Inventory count. I created a command buton (AddRecord) and added the following code:
-------------------------------------------------------
Private Sub AddRecord_Click()
Dim dbs As DAO.Database
Dim rst As DAO.Recordset
Set dbs = CurrentDb
Set rst = dbs.OpenRecordset("Items", dbOpenTable)
rst.Index = "PrimaryKey"
rst.Seek "=", Me!ItemID
rst.Edit
rst("ItemsInv") = rst("ItemsInv") - Me!Quantity
rst.Update
rst.Close
Set rst = Nothing
Set dbs = Nothing
End Sub
----------------------------------------------------------
It worked as expected up to one point.
I found out that it needed to be a "Front-End" and a "Back-end" solution. After I copied the database to create the "Back-End" database and linked the tables to the "Front-End", this procedure does not work any longer.
When I click on the "AddRecord" button it gives me the following error:
------------------------
Run-time error '3219':
Invalid operation
------------------------
When I click on the Debug button it takes me to the following location (highlighted in Yellow):
Set rst = dbs.OpenRecordset("Items", dbOpenTable)
Is this procedure not possible on "Linked" tables? And if it isn't what is the work around?
Any help is greatly appreciated. (I've read so much to get to this point and to find out that it's not working, is wrong!
)
While creating my "First Database" it being a OnLoan/inventory database I needed to create a process to remove "OnLoan" Items from the Inventory count. I created a command buton (AddRecord) and added the following code:
-------------------------------------------------------
Private Sub AddRecord_Click()
Dim dbs As DAO.Database
Dim rst As DAO.Recordset
Set dbs = CurrentDb
Set rst = dbs.OpenRecordset("Items", dbOpenTable)
rst.Index = "PrimaryKey"
rst.Seek "=", Me!ItemID
rst.Edit
rst("ItemsInv") = rst("ItemsInv") - Me!Quantity
rst.Update
rst.Close
Set rst = Nothing
Set dbs = Nothing
End Sub
----------------------------------------------------------
It worked as expected up to one point.
I found out that it needed to be a "Front-End" and a "Back-end" solution. After I copied the database to create the "Back-End" database and linked the tables to the "Front-End", this procedure does not work any longer.
When I click on the "AddRecord" button it gives me the following error:
------------------------
Run-time error '3219':
Invalid operation
------------------------
When I click on the Debug button it takes me to the following location (highlighted in Yellow):
Set rst = dbs.OpenRecordset("Items", dbOpenTable)
Is this procedure not possible on "Linked" tables? And if it isn't what is the work around?
Any help is greatly appreciated. (I've read so much to get to this point and to find out that it's not working, is wrong!