473,387 Members | 1,722 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,387 software developers and data experts.

How to overwrite an appended record in another table using a recordset

547 512MB
I use this code and it works great to append records from a subform to a table.
The problem comes in when you make a typo, as the record is then already appended to the table where its stored.
I need to be able to correct an error in the subform, and then it appends the corrected data to the same line in the table where its stored, instead of creating a new line/record everytime you correct something and press enter
Expand|Select|Wrap|Line Numbers
  1. Private Sub Form_AfterUpdate()
  2.   On Error GoTo Err_Form_AfterUpdate
  3.    Dim MyDB As DAO.Database
  4.    Dim rstEntry As DAO.Recordset
  5.  
  6.     Set MyDB = CurrentDb
  7.    Set rstEntry = MyDB.OpenRecordset("Fis_CaptDataT", dbOpenDynaset, dbAppendOnly)
  8.  
  9.     With rstEntry
  10.      .AddNew
  11. ![Client_lookup] = Me![Client_lookup]
  12. ![InvoiceDate] = Me![InvoiceDate]
  13.    ![Item_Lookup] = Me![Item_Lookup]
  14.  ![CPrice] = Me![Price]
  15.  ![Providers] = Me![Providers]
  16.  ![Supplier] = Me![Supplier Lookup]
  17. ![Order_No] = Me![Order_No]
  18.     ![OrderQty] = Me![OrderQty]
  19.       ![DataCapturer] = Me![DataCapturer]
  20.       ![Transact] = Me![Transaction]
  21.  
  22.      .Fields("Transaction" & CStr(Me![Transaction])) = Me![InvoiceQty]
  23.  
  24.     .update
  25.   End With
  26.  
  27.    rstEntry.close
  28.    Set rstEntry = Nothing
  29. Exit_Form_AfterUpdate:
  30.   Exit Sub
  31.  
  32. Err_Form_AfterUpdate:
  33.    MsgBox Err.Description, vbExclamation, "Error in Form_AfterUpdate()"
  34.     Resume Exit_Form_AfterUpdate
  35.  
  36.   End Sub
  37.  
Dec 15 '10 #1
2 2144
gershwyn
122 100+
Why are you using code to copy data from the form to the table, instead of just using a bound form to begin with? If you bind the form to the table (or a query based off the table) you would be able to edit any typos without having to jump through a bunch of coding hoops to do so.
Dec 15 '10 #2
neelsfer
547 512MB
i have about 10 different "transactions" that each get copied into its own column (field), from where the data is manipulated for my reports.
I initially used queries and it worked, but it was extremely slow and affected the applications speed.
Doing it this way, it takes me 1 second to produce a report, instead of up to 30 sec previously on the same pc across a network.
The whole capturing process is now also very fast (it previously slowed down when a number of users were logged in at same time).
After capturing the data in the subform, appending it to another table (where my reports are linked to), i delete the original data tables on exit.(i have an edit form linked to this table with the data, if needs to be).
I currently add about 10 000 records per month to the system.
I hope it makes sense why i do it this way.
Dec 15 '10 #3

Sign in to post your reply or Sign up for a free account.

Similar topics

7
by: Drew | last post by:
I have a db table like the following, UID, int auto-increment RegNo Person Relation YearsKnown Now here is some sample data from this table,
25
by: dixie | last post by:
I have some code that adds new records into a table for each ID in a list box when a button on a form is clicked. This works fine. My problem now is that I wish to be able to edit all the records...
1
by: news.sbcglobal.net | last post by:
Hi! I am able to add records to my SQL 2005 database using bound forms in my Access application, but if I try to edit any records (not only the new records I create) using the same bound forms,...
10
by: cbhavsar | last post by:
hello everybody, I am new with access and vba. I am creating a project where i have two type of user one is 'Admin' and another is 'User'. Now when anybody try to login into database , database...
3
by: mydans | last post by:
Hi Please I need help on how to find, add new, edit records using textboxes on a form, using VB6 and access 97. The following are my 7 fields StudentID, Name, DateOfReg , Address, ...
2
by: Hansel Haycox | last post by:
In access 2007, I created a query. I used the query and an additional table to create the form using Wizard. Yet, when I open the form, I am unable to edit existing records or add new records. I...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.