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 - Private Sub Form_AfterUpdate()
-
On Error GoTo Err_Form_AfterUpdate
-
Dim MyDB As DAO.Database
-
Dim rstEntry As DAO.Recordset
-
-
Set MyDB = CurrentDb
-
Set rstEntry = MyDB.OpenRecordset("Fis_CaptDataT", dbOpenDynaset, dbAppendOnly)
-
-
With rstEntry
-
.AddNew
-
![Client_lookup] = Me![Client_lookup]
-
![InvoiceDate] = Me![InvoiceDate]
-
![Item_Lookup] = Me![Item_Lookup]
-
![CPrice] = Me![Price]
-
![Providers] = Me![Providers]
-
![Supplier] = Me![Supplier Lookup]
-
![Order_No] = Me![Order_No]
-
![OrderQty] = Me![OrderQty]
-
![DataCapturer] = Me![DataCapturer]
-
![Transact] = Me![Transaction]
-
-
.Fields("Transaction" & CStr(Me![Transaction])) = Me![InvoiceQty]
-
-
.update
-
End With
-
-
rstEntry.close
-
Set rstEntry = Nothing
-
Exit_Form_AfterUpdate:
-
Exit Sub
-
-
Err_Form_AfterUpdate:
-
MsgBox Err.Description, vbExclamation, "Error in Form_AfterUpdate()"
-
Resume Exit_Form_AfterUpdate
-
-
End Sub
-
2 2144
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.
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.
Sign in to post your reply or Sign up for a free account.
Similar topics
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,
|
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...
|
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,...
|
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...
|
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, ...
|
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...
|
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,...
|
by: Charles Arthur |
last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
|
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...
|
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...
|
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
|
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...
|
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,...
|
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...
|
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,...
| |