 |
| Access Discussion of Microsoft Access database design and programming. See also the forums for Access ASP and Access VBA. |
Welcome to the p2p.wrox.com Forums.
You are currently viewing the Access section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
|
|
|
|

September 17th, 2003, 04:38 AM
|
|
Registered User
|
|
Join Date: Sep 2003
Posts: 8
Thanks: 0
Thanked 0 Times in 0 Posts
|
|
how to undo the multiple record ???
hi, i faced a pronlem that i can only undo one record instead of multiple records on the same subform
here is my code:
private sub btnundo_click()
On Error Resume Next
Application.Echo (False)
Me![TerminalFaultDetail Subform2].SetFocus
DoCmd.SetWarnings False
DoCmd.RunCommand acCmdUndo
Me![ComponetUsed Subform7].SetFocus
DoCmd.SetWarnings False
DoCmd.RunCommand acCmdUndo
Me!btnClose.SetFocus
Application.Echo (True)
case 1:
example , for TerminalFaultDetail Subform2 :
faultlink = 2
faultlink = 3
and i change them to
faultlinlk = 4
faultlink = 1
the result return to me is
faultLink = 4
faultLink id = 3 instead of
faultlink = 2
faultlink = 3
case 2 :
faultlink = 1
and i go to edit and add at the same time to:
faultlink = 2
faultlink = 3 (which is new record just added)
the result give me
faultlik = 2
(blank) means the new record is delete
instead of faultlink = 1
(blank)
*** for more clearer ....
i had btnundo which once user click on it, it will undo all the changes on the subform no matter how many rows that they had made changes, include adding the new records.
let for this subform,
Fault = 22
fault = 33
after i change it abd add a new record it is :
Fault = 44
fault = 21
fault = 11(which is the new record i added)
so once i click the undo button, it will be
back to the previous and maintain
Fault = 22
Fault = 33
could anyone help me please, im new to microsoft acess and i don't know how to do it, please help!!
|
|

September 17th, 2003, 04:51 AM
|
|
Registered User
|
|
Join Date: Sep 2003
Posts: 4
Thanks: 0
Thanked 0 Times in 0 Posts
|
|
Try this in the OnClick event of your button...
Code:
Private Sub YourButton_Click()
If Me.Dirty Then
Me.Undo
Else
MsgBox "There is nothing to undo"
End If
End Sub
HTH
IMO
|
|

September 17th, 2003, 10:52 PM
|
|
Registered User
|
|
Join Date: Sep 2003
Posts: 8
Thanks: 0
Thanked 0 Times in 0 Posts
|
|
hi, actually my code is working but only gpt one bug! the bug is i only can undo one record but not more than one,
What i want is
eg, originally
Fault = 1
Fault = 2
then if the user made changes to it, eg
Fault = 6
Fault = 5
then if user click the undo button , the result should be ** the 2 records taht user had made back to original one
Fault = 1
Fault = 2
but what i faced is if user click click the undo button the result is
Fault = 6
Fault = 2
** which only undo the last record only
do u have any idea that can modified my code to solve this problem or other way to do it????
|
|

September 18th, 2003, 02:31 AM
|
|
Registered User
|
|
Join Date: Sep 2003
Posts: 4
Thanks: 0
Thanked 0 Times in 0 Posts
|
|
When you enter changes to the subform, or new records, as soon as the subform loses focus, the record is saved.
The easy way around this is to ask for confirmation for changes whenever the subform is changed by using the before_Update event of the subform. This will then trap when the next button is pressed etc and allow you to undo. The downside is that it will always ask for confimation if you make any changes.
HTH
IMO
|
|

September 18th, 2003, 03:24 AM
|
|
Registered User
|
|
Join Date: Sep 2003
Posts: 8
Thanks: 0
Thanked 0 Times in 0 Posts
|
|
yea, i also trap them to let them know if they had made changes, but i also have button undo so that they can click button undo if they decide don't want to make changes
|
|

September 18th, 2003, 03:26 AM
|
|
Registered User
|
|
Join Date: Sep 2003
Posts: 8
Thanks: 0
Thanked 0 Times in 0 Posts
|
|
I had try this out to undo subform transactions, but i still got many bugs:
i have 3 tables:, Terminalfault, TerminalFaultDetail, Componetused
i had created form by using the above 3 tables:
the mainform is call FrmFault:
FaultDate:
SerialNUmber:
FaultNUmber:
*** subform call subform1
FaultNUmber:
Fault:
***** subform call Component
Component Number:
Component Quantity
** for subform1 one faultNumber can have many fault , eg
FaultNUmber = 111 Fault = 22
faultnumber = 111 Fault = 23 and so on
** similiar to the Component subform
Component Number = 1111 Component Quantity = 2
Component NUmber = 1111 component Quantity = 3
i tried to apply the code of subforms transactions from microosoft access 2000 but i don't really understand it
this is my undo module:
Option Compare Database
Option Explicit
Private mwks As DAO.Workspace
Private mfIntrans As Boolean
Const adhcSource As String = "subform1"
*** but unfortunately i didn't create the query , so can i admit this line "Const adhcSource As String = "subform1"
Private Sub resetdata()
Dim db As DAO.Database
Dim qdf As DAO.QueryDef
Dim rst As DAO.Recordset
Dim prm As DAO.Parameter
Dim strsource As String
If mfIntrans Then
mwks.CommitTrans
End If
Set mwks = DBEngine.CreateWorkspace("mwks", "Admin", "")
Set db = mwks.OpenDatabase(CurrentDb.Name)
Set qdf = db.QueryDefs(mstrsource)
For Each prm In qdf.Parameters
prm.Value = Eval(prm.Name)
Next prm
Me.Painting = False
Set rst = qdf.OpenRecordset
rst.LockEdits = False
Set Form_subform1.Form.recorset = rst
Me.Painting = True
mwks.BeginTrans
mfIntrans = True
End Sub
** similiar to these code, i didn't create the query so it is not working, so do i modify it as i didn't create a query???
Me.undo
If mfIntrans Then
mwks.Rollback
mfIntrans = False
FaultDate.SetFocus
Call resetdata
End If
Could you please help me , thank you very much!!!
** have you done this before???
|
|

April 20th, 2004, 04:14 AM
|
|
Registered User
|
|
Join Date: Jun 2003
Posts: 2
Thanks: 0
Thanked 0 Times in 0 Posts
|
|
Still need an answer?
You can do it very easy dy assining a ADO Recordset to your subform, based on a single connection, and have the button in the main form to Commit changes or undo the entire transaction...
If you need more help, post here...
|
|
 |