|
|||||||
![]() |
|
|
LinkBack | Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
|
#1 |
|
Member (7 bit)
Join Date: Jul 2005
Location: Arizona
Posts: 108
|
Adding/Editing MS Access records in VB
I have a Access database that I created for work to keep track of our inventory. All the forms access and edit data from one table. I need to create a way to keep track of when data in that table is changed, and how it is changed. It's been about 10 years since I took an Access class, so I'm rusty to say the least.
I created a new table with fields for the date, time, item name, number used, and number received. My idea was to add a new record to that table every time the inventory table was modified through the forms. I just can't figure out how to access the activity table through the VBasic code I've scratched together. Any ideas would be appreciated. |
|
|
|
|
|
#2 |
|
Come in Ray...
Join Date: Sep 2004
Posts: 1,668
|
Are you using VB to interface with your Access DB or are you using VB forms built into Access? It sounds to me like the entire thing should be done in Access (VB code and forms), this way you can easily bind data fields and add record navigors to forms. Access has a multitude of wizards which will do this for you.
|
|
|
|
|
|
#3 | |
|
Member (7 bit)
Join Date: Jul 2005
Location: Arizona
Posts: 108
|
I'm using the VB in Access, to code the events when you click on the save button, etc.
For instance, the Use Item form draws it's data from the Inventory table. They select an item from the combo box, enter in how many they've used, and click save. The code then adjusts the values to reflect the current inventory levels, and saves the record. Quote:
|
|
|
|
|
|
|
#4 |
|
Come in Ray...
Join Date: Sep 2004
Posts: 1,668
|
In your save event button, simply add the Access code to run an update SQL statement:
DoCmd.RunSQL "INSERT INTO other_table(field1, field2, field3) VALUES(field1value, field2value, field3value);" |
|
|
|
|
|
#5 | |
|
Member (7 bit)
Join Date: Jul 2005
Location: Arizona
Posts: 108
|
When I did take my access class, I think there was about a half a paragraph on SQL code, so I'm probably butchering this up pretty badly. I keep getting syntax errors.
I've tried all of these... Quote:
|
|
|
|
|
|
|
#6 | |
|
Come in Ray...
Join Date: Sep 2004
Posts: 1,668
|
Quote:
Here is an example: "INSERT INTO table (string_value, date_value, string_value_with_appostrophe) VALUES ('new value', #1/1/2005#, 'What''s up?'); |
|
|
|
|
|
|
#7 | |
|
Member (7 bit)
Join Date: Jul 2005
Location: Arizona
Posts: 108
|
Thank you Faulkner! I had to mess around with it, to get it to work, but it's working.
It's messy, but this is the only way I could get it to work. Quote:
Last edited by Med; 11-04-2005 at 05:17 PM. |
|
|
|
|
![]() |
| Bookmarks |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|