473,513 Members | 3,208 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

What's the best method to 'batch process' records from a data entry session?

stonward
145 New Member
Hi Guys,

I have a system that includes a Purchase form and a Purchase Details subform, one to many relationship etc.

What is the best way to 'hold' the records entered into the subform, before committing them to disc. The customer needs to be able to check the entered data before it has been saved in the table.

I've thought of make table queries and have been experimenting with recordset clones, but am certainly not an expert with DAO/ADO programming. However, if i knew the best/preferred method then I would narrow down how much new I have to learn.

The fields I need to save are called, PurchaseDetailsID, PurchaseID, ProductID, UnitCost and Quantity - the fields of the PurchaseDetails table. Usually there are not more than 6 rows of such data entered each time.


Many thanks for your time,

RPE.
May 4 '12 #1
10 3322
TheSmileyCoder
2,322 Recognized Expert Moderator Top Contributor
You cannot use transactions covering both the main form and the subform as far as I know. Thus the only viable solution is to use a table with temporary values, and then tie the saving/updating of subform records into the main forms navigation (I.e. update child records in live table when main form navigates to another record, or closes)
May 7 '12 #2
NeoPa
32,557 Recognized Expert Moderator MVP
Check out BeginTrans in the Context-Sensitive Help. It would have to be understood well before using, but it may allow you to achieve your aim.

FYI: DBEngine.Workspaces(0).Name == "#Default Workspace#"
May 7 '12 #3
stonward
145 New Member
Thanks for your help SmileyCoder.

I figured that temporary tables would be a likely method, but have found it 'clunky' at best so far.

I can't believe this problem has become so difficult to solve...but generally when I have come across such an impasse in Access before, it simply means I have started with faulty fundamentals!

Thanks again,

Stonward.
May 9 '12 #4
NeoPa
32,557 Recognized Expert Moderator MVP
Had to reset the Best Answer I'm afraid as it's factually incorrect. Transactions work at the WorkSpace level and, as such, can cover multiple disparate tables and even separate databases, as long as they are within the same WorkSpace.
May 9 '12 #5
TheSmileyCoder
2,322 Recognized Expert Moderator Top Contributor
I still stand by my answer. If it were as simple as you imply, then the following should work fine. Create a main form with a subform. In the main form, add 2 buttons btn_Cancel, and btn_SaveAndExit, and the following code:

Expand|Select|Wrap|Line Numbers
  1. Option Compare Database
  2. Option Explicit
  3. Private ws As DAO.Workspace
  4.  
  5. Private Sub Btn_Cancel_Click()
  6.    ws.Rollback
  7.    DoCmd.Close
  8. End Sub
  9.  
  10. Private Sub btn_SaveAndExit_Click()
  11.    ws.CommitTrans
  12.    DoCmd.Close
  13. End Sub
  14.  
  15. Private Sub Form_Close()
  16.    Set ws = Nothing
  17. End Sub
  18.  
  19. Private Sub Form_Open(Cancel As Integer)
  20.    Set ws = DAO.DBEngine.Workspaces(0)
  21.    Debug.Print "Workspaces:" & DBEngine.Workspaces.Count
  22.    ws.BeginTrans
  23. End Sub
However, when testing it seems all changes are commited regardless of which button is pushed.

I believe that Access handles the data changes in a seperate hidden workspace, and that is why the above does not work. If you (NeoPa) or anyone else has suggestions I am all eyes to look at it.
May 9 '12 #6
TheSmileyCoder
2,322 Recognized Expert Moderator Top Contributor
You can expand on the above by getting the db object from the workspace, and base the forms recordsets off said db like so:
Expand|Select|Wrap|Line Numbers
  1. Private Sub Form_Close()
  2.    Set Me.Recordset = Nothing
  3.    Set Me.frm_Sub.Form.Recordset = Nothing
  4.    Set ws = Nothing
  5. End Sub
  6.  
  7. Private Sub Form_Open(Cancel As Integer)
  8.    Set ws = DAO.DBEngine.Workspaces(0)
  9.    Set curDb = ws.Databases(0)
  10.    Set Me.Recordset = curDb.OpenRecordset(Me.RecordSource, dbOpenDynaset)
  11.    Set Me.frm_Sub.Form.Recordset = curDb.OpenRecordset(Me.frm_Sub.Form.RecordSource, dbOpenDynaset)
  12.    ws.BeginTrans
  13. End Sub
  14.  
However you loose alot of the built in access funtionality. For instance the parent/child relation is no longer automatically enforced (All child records for all parent records are shown in subform, new child records do not automatically get the correct foreign key assigned.)

Im sure its possible, but I am also sure it will involve alot of extra coding (But PLEASE prove me wrong, and provide an elegant solution, I know of several places I could use it)
May 9 '12 #7
NeoPa
32,557 Recognized Expert Moderator MVP
I'm afraid I can't do that now Smiley as that would take more time than I have.

I will say that I expect you may be right as I was only going on the information available in the Help System, and I know that has led me astray in the past. I will add it to my list of things to try, but why not send me a sample db to play with and test out. I will see if I can find a way to implement the logic as explained by the Help System. You have my Skype details. NB. I still only use 2003.
May 9 '12 #8
NeoPa
32,557 Recognized Expert Moderator MVP
I did a test and found very similar results to you Smiley. IE. Nothing in a form seems to be managed within a transaction. I too, assumed this might be due to another Workspace object managing all Forms / Reports, but I ran the following code (between updating a control value and moving from the record to trigger changes to be saved) in the Immediate Pane and got the results shown (only) :
Expand|Select|Wrap|Line Numbers
  1. for each ws in DBEngine.Workspaces:?ws.Name:Next ws
  2. #Default Workspace#
The code I used was very basic and inside a simple Form that allows updating of records in a local table (The Help System indicates it won't work with ODBC connections anyway).
Expand|Select|Wrap|Line Numbers
  1. Option Compare Database
  2. Option Explicit
  3.  
  4. Private blnTran As Boolean
  5.  
  6. Private Sub Form_Open(Cancel As Integer)
  7.     Call DBEngine.BeginTrans
  8.     blnTran = True
  9. End Sub
  10.  
  11. Private Sub cmdCommit_Click()
  12.     Call CommitTrans(dbForceOSFlush)
  13.     blnTran = False
  14.     Call DoCmd.Close
  15. End Sub
  16.  
  17. Private Sub Form_Close()
  18.     If blnTran Then Call Rollback
  19. End Sub
Line #18 consistently called Rollback, but never with any effect.

I'd better go back and set post #2 back to Best Answer.
May 9 '12 #9
TheSmileyCoder
2,322 Recognized Expert Moderator Top Contributor
From the access 2010 context sensitive help on workspaces:
Access 2010 Help
Access Developer Reference
DBEngine.Workspaces Property
Returns a Workspaces collection that contains all of the active, unhidden Workspace objects. Read-only.
Syntax

expression.Workspaces

expression A variable that represents a DBEngine object.
This would seem to indicate that there can be hidden workspaces, and I am guessing thats why you are not seing the workspace used, when looping through the collection.
May 9 '12 #10
NeoPa
32,557 Recognized Expert Moderator MVP
Ah. Well spotted young man :-) That would tend to indicate that it may well be, as you say, contained within a hidden workspace.

All we need now is to identify the hidden workspace used, and to determine if all forms are opened within that single workspace, or whether each object is opened within its own, separate, workspace.

I tried to determine the workspace associated with a form but was unsuccessful at finding anything remotely helpful.
May 9 '12 #11

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

Similar topics

3
6367
by: | last post by:
Hi, I am an intermediate computer science student and I am in need of a "macro type" tool/language that will let me automate a data entry process. The data entry is rather simple but requires...
2
2006
by: Dalan | last post by:
I have created a table and form for allowing the input of a unique customer number (not an ID autonumber number) which a customer would enter once after installing the database. I'm using DLookup...
5
3927
by: Nancy | last post by:
I have two tables: TblCourse CourseID CourseName TblClass ClassID CourseID ClassDate
2
1076
by: James Radke | last post by:
Hello, I have a web application that contains class 'X' (note that this is one class of many contained in the application). Now, we need to create a pc based windows application which will use...
2
2048
by: ilikebirds | last post by:
Access 2003: I notice that on a form there is a menu for RECORDS - Data Entry. What occurs here is when data is updated and the option is selected It enters the data into the table and starts...
4
2752
by: ink | last post by:
Hi all, I am trying to pull some financial data off of an HTML web page so that I can store it in a Database for Sorting and filtering. I have been thinking about this for some time and trying...
1
1586
by: olddocks | last post by:
what is the best method to process the form on the same page with PHP? How to do it?
1
2145
by: FX1Media | last post by:
I am looking for input on the best method to interact with data in a C#/Visual Studio Windows Forms application using an SQL database. I have limited experience working with data in this scenario....
0
1389
by: nick belshaw | last post by:
using PyGtk - no problems. I can draw onto an Image using a PixBuf, Drawable etc pixbuf = image.get_pixbuf() drawable = pixbuf.render_pixmap_and_mask()...
1
2470
by: Amar Agundu | last post by:
Hello, I am developing webapplication in JSP.I have a resultset fetched from database.This contains records with many columns but I want to display them on a page in a neat manner.What is best way to...
0
7153
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
7373
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,...
0
7519
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
1
5079
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...
0
4743
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...
0
3230
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The...
0
3218
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
0
1585
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated ...
0
452
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence...

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.