|
 |
access thread: undo procedure
Message #1 by "Howard Stone" <ququmber@h...> on Tue, 21 May 2002 03:22:16
|
|
I have a command button named cmdFilter on a form that when clicked
filters a form and bring up one record only that allows the user to edit
this record.
I want to put a second button named cmdCancel that will undo any changes
made before saving record.
What procedure could I use with this command button.
Thanks
Message #2 by John Fejsa <John.Fejsa@h...> on Tue, 21 May 2002 12:25:49 +1000
|
|
Me.Undo
____________________________________________________
John Fejsa
Systems Analyst/Computer Programmer
Hunter Centre for Health Advancement
Locked Bag 10, WALLSEND NSW 2287
Phone: (02) 4924 6336 Fax: (02) 4924 6209
www.hcha.org.au
____________________________________________________
The doors we open and close each day decide the lives we live
____________________________________________________
CONFIDENTIALITY & PRIVILEGE NOTICE
The information contained in this email message is intended for the named
addressee only. If you are not the intended recipient you must not copy,
distribute, take any action reliant on, or disclose any details of the
information in this email to any other person or organisation. If you
have received this email in error please notify us immediately.
>>> ququmber@h... 21/05/2002 13:22:16 >>>
I have a command button named cmdFilter on a form that when clicked
filters a form and bring up one record only that allows the user to
edit
this record.
I want to put a second button named cmdCancel that will undo any changes=20
made before saving record.
What procedure could I use with this command button.
Thanks
This message is intended for the addressee named and may contain confidential information. If you are not the intended recipient,
please delete it and notify the sender. Views expressed in this message are those of the individual sender, and are not necessarily
the views of Hunter Health.
Message #3 by "Howard Stone" <ququmber@h...> on Tue, 21 May 2002 03:46:33
|
|
Thanks for the quick response but it did not work.
The form I am working with has two subforms and writing that code on a
command button does not undo the change.
I may be doing something wrong and not knowing
Message #4 by "John Ruff" <papparuff@c...> on Mon, 20 May 2002 20:26:57 -0700
|
|
Once you move to a subform after making changes to a main form, you
cannot undo changes to the main form using undo because the changes have
already been saved. The same goes for a subform. When you make a
change in a subform and move to the parent form or to another subform,
those changes are saved in the subform and again, the undo command will
not work.
One way to resolve this this issue is to save the old values for the
appropriate controls in their Tag property. You could use the
AfterUpdate event of each control to accomplish this, something like;
Private Sub txtName_AfterUpdate()
txtName.Tag=txtName.OldValue
end if
Then in the Undo command button's On Click Event you can enumerate
through all the controls in the main form, verify that there is a value
in the control's Tag property, replace the current value of the control
with the value in the control's Tag property, then set the Tag property
to "".
Private cmdUndo_Click()
Dim ctl as control
' Enumerate through each control on the form
For each ctl in Me.Controls
' If the control is a textbox or a combobox then...
' (you can add more controltypes if you wish
If ctl.controltype=actextbox _
or ctl.controltype=accombobox then
' Test for anything in the Tag property of the
control
If ctl.Tag<>"" then
' Let the control's value equal it's old
value
Ctl.value=ctl.tag
End if
End if
Next ctl
You would then go through the process for each of the subforms.
John Ruff - The Eternal Optimist :-)
Always Looking for a Contract Opportunity
xxx.xxx.xxxx
9306 Farwest Dr SW
Lakewood, WA 98498
-----Original Message-----
From: Howard Stone [mailto:ququmber@h...]
Sent: Tuesday, May 21, 2002 3:47 AM
To: Access
Subject: [access] Re: undo procedure
Thanks for the quick response but it did not work.
The form I am working with has two subforms and writing that code on a
command button does not undo the change.
I may be doing something wrong and not knowing
Message #5 by "Carnley, Dave" <dcarnley@a...> on Tue, 21 May 2002 09:32:42 -0500
|
|
this is good, but has a bug in it - if a user changes any field more than
once, it will only revert on undo to the one most previous value.
Of course it depends on what is intended, if just a 'most recent change
Undo' is needed, thsi will work for that, but I think the original question
was looking more fore a complete revert to original values, so I would
suggest this:
Instead of setting the field tags in the _AfterUpdate event, set ALL the
tags on form-load (or when they select a new record to look at) one time
with the original values. Then on revert the current value is compared to
the original in every field.
-----Original Message-----
From: John Ruff [mailto:papparuff@c...]
Sent: Monday, May 20, 2002 10:27 PM
To: Access
Subject: [access] Re: undo procedure
Once you move to a subform after making changes to a main form, you
cannot undo changes to the main form using undo because the changes have
already been saved. The same goes for a subform. When you make a
change in a subform and move to the parent form or to another subform,
those changes are saved in the subform and again, the undo command will
not work.
One way to resolve this this issue is to save the old values for the
appropriate controls in their Tag property. You could use the
AfterUpdate event of each control to accomplish this, something like;
Private Sub txtName_AfterUpdate()
txtName.Tag=txtName.OldValue
end if
Then in the Undo command button's On Click Event you can enumerate
through all the controls in the main form, verify that there is a value
in the control's Tag property, replace the current value of the control
with the value in the control's Tag property, then set the Tag property
to "".
Message #6 by "Howard Stone" <ququmber@h...> on Wed, 22 May 2002 05:14:08
|
|
I tried the following procedure:
Private Sub Form_Load()
Dim ctl As Control
For Each ctl In Me.Controls
If ctl.ControlType = acTextBox Or ctl.ControlType =
acComboBox Or ctl.ControlType = acCheckBox Then
ctl.Tag = ctl.OldValue
End If
Next ctl
Private Sub cmdCancel_Click()
Dim ctl As Control
For Each ctl In Me.Controls
If ctl.Type = acTextBox Or ctl.Type = acComboBox Or
ctl.Type = acCheckBox Then
ctl.Value = ctl.Tag
End If
Next ctl
End Sub
When the form loads I get a type mismatch error.
When I click cmdCancel button I get error "object does not support
property or method"
How do I resolve this?
Thanks
Message #7 by "John Ruff" <papparuff@c...> on Tue, 21 May 2002 21:15:51 -0700
|
|
There is no .OldValue when you first load a form. If the control hasn't
been edited, this code has no effect. This is why you are getting the
mismatch error.
You are getting the error "object does not support property or method"
in the second procedure because your code is incorrect. Instead of:
If ctl.Type = acTextBox Or _
ctl.Type = acComboBox Or _
ctl.Type = acCheckBox Then
it should be:
If ctl.ControlType = acTextBox Or _
ctl.ControlType = acComboBox Or _
ctl.ControlType = acCheckBox Then
John Ruff - The Eternal Optimist :-)
Always Looking for a Contract Opportunity
xxx.xxx.xxxx
9306 Farwest Dr SW
Lakewood, WA 98498
-----Original Message-----
From: Howard Stone [mailto:ququmber@h...]
Sent: Wednesday, May 22, 2002 5:14 AM
To: Access
Subject: [access] Re: undo procedure
I tried the following procedure:
Private Sub Form_Load()
Dim ctl As Control
For Each ctl In Me.Controls
If ctl.ControlType = acTextBox Or ctl.ControlType
acComboBox Or ctl.ControlType = acCheckBox Then
ctl.Tag = ctl.OldValue
End If
Next ctl
Private Sub cmdCancel_Click()
Dim ctl As Control
For Each ctl In Me.Controls
If ctl.Type = acTextBox Or ctl.Type = acComboBox Or
ctl.Type = acCheckBox Then
ctl.Value = ctl.Tag
End If
Next ctl
End Sub
When the form loads I get a type mismatch error.
When I click cmdCancel button I get error "object does not support
property or method"
How do I resolve this?
Thanks
Message #8 by "Howard Stone" <ququmber@h...> on Wed, 22 May 2002 06:15:42
|
|
Thanks John, I tried by changing ctl.OldValue in the Load() procedure to
ctl.Value and got no error message.
I also did the correction as suggested in the Click() procedure and now
getting an error message saying "You can't assign a value to this
object". I am unable to figure out the problem.
Thanks
There is no .OldValue when you first load a form. If the control hasn't
been edited, this code has no effect. This is why you are getting the
mismatch error.
You are getting the error "object does not support property or method"
in the second procedure because your code is incorrect. Instead of:
If ctl.Type = acTextBox Or _
ctl.Type = acComboBox Or _
ctl.Type = acCheckBox Then
it should be:
If ctl.ControlType = acTextBox Or _
ctl.ControlType = acComboBox Or _
ctl.ControlType = acCheckBox Then
John Ruff - The Eternal Optimist :-)
Always Looking for a Contract Opportunity
xxx.xxx.xxxx
9306 Farwest Dr SW
Lakewood, WA 98498
-----Original Message-----
From: Howard Stone [mailto:ququmber@h...]
Sent: Wednesday, May 22, 2002 5:14 AM
To: Access
Subject: [access] Re: undo procedure
I tried the following procedure:
Private Sub Form_Load()
Dim ctl As Control
For Each ctl In Me.Controls
If ctl.ControlType = acTextBox Or ctl.ControlType
acComboBox Or ctl.ControlType = acCheckBox Then
ctl.Tag = ctl.OldValue
End If
Next ctl
Private Sub cmdCancel_Click()
Dim ctl As Control
For Each ctl In Me.Controls
If ctl.Type = acTextBox Or ctl.Type = acComboBox Or
ctl.Type = acCheckBox Then
ctl.Value = ctl.Tag
End If
Next ctl
End Sub
When the form loads I get a type mismatch error.
When I click cmdCancel button I get error "object does not support
property or method"
How do I resolve this?
Thanks
Message #9 by "John Ruff" <papparuff@c...> on Tue, 21 May 2002 23:18:20 -0700
|
|
Howard,
I apologize for the confusion Howard. You still need to dimension the
ctl and use the for next loop. Your code should look like this:
Private Sub cmdCancel_Click()
Dim ctl As Control
For Each ctl In Me.Controls
If ctl.ControlType = acTextBox Or _
ctl.ControlType = acComboBox Or _
ctl.ControlType = acCheckBox Then
ctl.Value = ctl.Tag
End If
Next ctl
End Sub
I also modified the procedure to make it a little more readable and
indiscernibly faster:
Private Sub cmdCancel_Click()
Dim ctl As Control
For Each ctl In Me.Controls
Select Case ctl.ControlType
Case acTextBox, acComboBox, acCheckBox
ctl.Value = ctl.Tag
End Select
Next ctl
End Sub
John Ruff - The Eternal Optimist :-)
Always Looking for a Contract Opportunity
xxx.xxx.xxxx
9306 Farwest Dr SW
Lakewood, WA 98498
-----Original Message-----
From: Howard Stone [mailto:ququmber@h...]
Sent: Wednesday, May 22, 2002 6:16 AM
To: Access
Subject: [access] Re: undo procedure
Thanks John, I tried by changing ctl.OldValue in the Load() procedure
to
ctl.Value and got no error message.
I also did the correction as suggested in the Click() procedure and now
getting an error message saying "You can't assign a value to this
object". I am unable to figure out the problem.
Thanks
There is no .OldValue when you first load a form. If the control
hasn't
been edited, this code has no effect. This is why you are getting the
mismatch error.
You are getting the error "object does not support property or method"
in the second procedure because your code is incorrect. Instead of:
If ctl.Type = acTextBox Or _
ctl.Type = acComboBox Or _
ctl.Type = acCheckBox Then
it should be:
If ctl.ControlType = acTextBox Or _
ctl.ControlType = acComboBox Or _
ctl.ControlType = acCheckBox Then
John Ruff - The Eternal Optimist :-)
Always Looking for a Contract Opportunity
xxx.xxx.xxxx
9306 Farwest Dr SW
Lakewood, WA 98498
-----Original Message-----
From: Howard Stone [mailto:ququmber@h...]
Sent: Wednesday, May 22, 2002 5:14 AM
To: Access
Subject: [access] Re: undo procedure
I tried the following procedure:
Private Sub Form_Load()
Dim ctl As Control
For Each ctl In Me.Controls
If ctl.ControlType = acTextBox Or ctl.ControlType
acComboBox Or ctl.ControlType = acCheckBox Then
ctl.Tag = ctl.OldValue
End If
Next ctl
Private Sub cmdCancel_Click()
Dim ctl As Control
For Each ctl In Me.Controls
If ctl.Type = acTextBox Or ctl.Type = acComboBox Or
ctl.Type = acCheckBox Then
ctl.Value = ctl.Tag
End If
Next ctl
End Sub
When the form loads I get a type mismatch error.
When I click cmdCancel button I get error "object does not support
property or method"
How do I resolve this?
Thanks
Message #10 by "Howard Stone" <ququmber@h...> on Wed, 22 May 2002 12:31:04
|
|
John:
I did exactly as you stated making sure the codes are correct and I am
still getting Run-time error 2448 saying "You can't assign a value to this
object" when I click the command button to Undo.
Also I code all the sub forms indivually with the Form Load event.
Any thing I am overlooking to tell you that is causing this error ?
Howard
I apologize for the confusion Howard. You still need to dimension the
ctl and use the for next loop. Your code should look like this:
Private Sub cmdCancel_Click()
Dim ctl As Control
For Each ctl In Me.Controls
If ctl.ControlType = acTextBox Or _
ctl.ControlType = acComboBox Or _
ctl.ControlType = acCheckBox Then
ctl.Value = ctl.Tag
End If
Next ctl
End Sub
I also modified the procedure to make it a little more readable and
indiscernibly faster:
Private Sub cmdCancel_Click()
Dim ctl As Control
For Each ctl In Me.Controls
Select Case ctl.ControlType
Case acTextBox, acComboBox, acCheckBox
ctl.Value = ctl.Tag
End Select
Next ctl
End Sub
John Ruff - The Eternal Optimist :-)
Always Looking for a Contract Opportunity
xxx.xxx.xxxx
9306 Farwest Dr SW
Lakewood, WA 98498
-----Original Message-----
From: Howard Stone [mailto:ququmber@h...]
Sent: Wednesday, May 22, 2002 6:16 AM
To: Access
Subject: [access] Re: undo procedure
Thanks John, I tried by changing ctl.OldValue in the Load() procedure
to
ctl.Value and got no error message.
I also did the correction as suggested in the Click() procedure and now
getting an error message saying "You can't assign a value to this
object". I am unable to figure out the problem.
Thanks
There is no .OldValue when you first load a form. If the control
hasn't
been edited, this code has no effect. This is why you are getting the
mismatch error.
You are getting the error "object does not support property or method"
in the second procedure because your code is incorrect. Instead of:
If ctl.Type = acTextBox Or _
ctl.Type = acComboBox Or _
ctl.Type = acCheckBox Then
it should be:
If ctl.ControlType = acTextBox Or _
ctl.ControlType = acComboBox Or _
ctl.ControlType = acCheckBox Then
John Ruff - The Eternal Optimist :-)
Always Looking for a Contract Opportunity
xxx.xxx.xxxx
9306 Farwest Dr SW
Lakewood, WA 98498
-----Original Message-----
From: Howard Stone [mailto:ququmber@h...]
Sent: Wednesday, May 22, 2002 5:14 AM
To: Access
Subject: [access] Re: undo procedure
I tried the following procedure:
Private Sub Form_Load()
Dim ctl As Control
For Each ctl In Me.Controls
If ctl.ControlType = acTextBox Or ctl.ControlType
acComboBox Or ctl.ControlType = acCheckBox Then
ctl.Tag = ctl.OldValue
End If
Next ctl
Private Sub cmdCancel_Click()
Dim ctl As Control
For Each ctl In Me.Controls
If ctl.Type = acTextBox Or ctl.Type = acComboBox Or
ctl.Type = acCheckBox Then
ctl.Value = ctl.Tag
End If
Next ctl
End Sub
When the form loads I get a type mismatch error.
When I click cmdCancel button I get error "object does not support
property or method"
How do I resolve this?
Thanks
Message #11 by "John Ruff" <papparuff@c...> on Wed, 22 May 2002 06:40:07 -0700
|
|
I don't know why you are getting this error as both sets of code work
perfectly on my machine. Please repost your code so it can be examined.
John Ruff - The Eternal Optimist :-)
Always Looking for a Contract Opportunity
xxx.xxx.xxxx
9306 Farwest Dr SW
Lakewood, WA 98498
-----Original Message-----
From: Howard Stone [mailto:ququmber@h...]
Sent: Wednesday, May 22, 2002 12:31 PM
To: Access
Subject: [access] Re: undo procedure
John:
I did exactly as you stated making sure the codes are correct and I am
still getting Run-time error 2448 saying "You can't assign a value to
this
object" when I click the command button to Undo.
Also I code all the sub forms indivually with the Form Load event.
Any thing I am overlooking to tell you that is causing this error ?
Howard
I apologize for the confusion Howard. You still need to dimension the
ctl and use the for next loop. Your code should look like this:
Private Sub cmdCancel_Click()
Dim ctl As Control
For Each ctl In Me.Controls
If ctl.ControlType = acTextBox Or _
ctl.ControlType = acComboBox Or _
ctl.ControlType = acCheckBox Then
ctl.Value = ctl.Tag
End If
Next ctl
End Sub
I also modified the procedure to make it a little more readable and
indiscernibly faster:
Private Sub cmdCancel_Click()
Dim ctl As Control
For Each ctl In Me.Controls
Select Case ctl.ControlType
Case acTextBox, acComboBox, acCheckBox
ctl.Value = ctl.Tag
End Select
Next ctl
End Sub
John Ruff - The Eternal Optimist :-)
Always Looking for a Contract Opportunity
xxx.xxx.xxxx
9306 Farwest Dr SW
Lakewood, WA 98498
-----Original Message-----
From: Howard Stone [mailto:ququmber@h...]
Sent: Wednesday, May 22, 2002 6:16 AM
To: Access
Subject: [access] Re: undo procedure
Thanks John, I tried by changing ctl.OldValue in the Load() procedure
to
ctl.Value and got no error message.
I also did the correction as suggested in the Click() procedure and now
getting an error message saying "You can't assign a value to this
object". I am unable to figure out the problem.
Thanks
There is no .OldValue when you first load a form. If the control
hasn't
been edited, this code has no effect. This is why you are getting the
mismatch error.
You are getting the error "object does not support property or method"
in the second procedure because your code is incorrect. Instead of:
If ctl.Type = acTextBox Or _
ctl.Type = acComboBox Or _
ctl.Type = acCheckBox Then
it should be:
If ctl.ControlType = acTextBox Or _
ctl.ControlType = acComboBox Or _
ctl.ControlType = acCheckBox Then
John Ruff - The Eternal Optimist :-)
Always Looking for a Contract Opportunity
xxx.xxx.xxxx
9306 Farwest Dr SW
Lakewood, WA 98498
-----Original Message-----
From: Howard Stone [mailto:ququmber@h...]
Sent: Wednesday, May 22, 2002 5:14 AM
To: Access
Subject: [access] Re: undo procedure
I tried the following procedure:
Private Sub Form_Load()
Dim ctl As Control
For Each ctl In Me.Controls
If ctl.ControlType = acTextBox Or ctl.ControlType
acComboBox Or ctl.ControlType = acCheckBox Then
ctl.Tag = ctl.OldValue
End If
Next ctl
Private Sub cmdCancel_Click()
Dim ctl As Control
For Each ctl In Me.Controls
If ctl.Type = acTextBox Or ctl.Type = acComboBox Or
ctl.Type = acCheckBox Then
ctl.Value = ctl.Tag
End If
Next ctl
End Sub
When the form loads I get a type mismatch error.
When I click cmdCancel button I get error "object does not support
property or method"
How do I resolve this?
Thanks
Message #12 by "Carnley, Dave" <dcarnley@a...> on Wed, 22 May 2002 09:49:00 -0500
|
|
maybe one of your controls is locked or not enabled?
-----Original Message-----
From: Howard Stone [mailto:ququmber@h...]
Sent: Wednesday, May 22, 2002 7:31 AM
To: Access
Subject: [access] Re: undo procedure
John:
I did exactly as you stated making sure the codes are correct and I am
still getting Run-time error 2448 saying "You can't assign a value to this
object" when I click the command button to Undo.
Also I code all the sub forms indivually with the Form Load event.
Any thing I am overlooking to tell you that is causing this error ?
Howard
I apologize for the confusion Howard. You still need to dimension the
ctl and use the for next loop. Your code should look like this:
Private Sub cmdCancel_Click()
Dim ctl As Control
For Each ctl In Me.Controls
If ctl.ControlType = acTextBox Or _
ctl.ControlType = acComboBox Or _
ctl.ControlType = acCheckBox Then
ctl.Value = ctl.Tag
End If
Next ctl
End Sub
I also modified the procedure to make it a little more readable and
indiscernibly faster:
Private Sub cmdCancel_Click()
Dim ctl As Control
For Each ctl In Me.Controls
Select Case ctl.ControlType
Case acTextBox, acComboBox, acCheckBox
ctl.Value = ctl.Tag
End Select
Next ctl
End Sub
John Ruff - The Eternal Optimist :-)
Always Looking for a Contract Opportunity
xxx.xxx.xxxx
9306 Farwest Dr SW
Lakewood, WA 98498
-----Original Message-----
From: Howard Stone [mailto:ququmber@h...]
Sent: Wednesday, May 22, 2002 6:16 AM
To: Access
Subject: [access] Re: undo procedure
Thanks John, I tried by changing ctl.OldValue in the Load() procedure
to
ctl.Value and got no error message.
I also did the correction as suggested in the Click() procedure and now
getting an error message saying "You can't assign a value to this
object". I am unable to figure out the problem.
Thanks
There is no .OldValue when you first load a form. If the control
hasn't
been edited, this code has no effect. This is why you are getting the
mismatch error.
You are getting the error "object does not support property or method"
in the second procedure because your code is incorrect. Instead of:
If ctl.Type = acTextBox Or _
ctl.Type = acComboBox Or _
ctl.Type = acCheckBox Then
it should be:
If ctl.ControlType = acTextBox Or _
ctl.ControlType = acComboBox Or _
ctl.ControlType = acCheckBox Then
John Ruff - The Eternal Optimist :-)
Always Looking for a Contract Opportunity
xxx.xxx.xxxx
9306 Farwest Dr SW
Lakewood, WA 98498
-----Original Message-----
From: Howard Stone [mailto:ququmber@h...]
Sent: Wednesday, May 22, 2002 5:14 AM
To: Access
Subject: [access] Re: undo procedure
I tried the following procedure:
Private Sub Form_Load()
Dim ctl As Control
For Each ctl In Me.Controls
If ctl.ControlType = acTextBox Or ctl.ControlType
acComboBox Or ctl.ControlType = acCheckBox Then
ctl.Tag = ctl.OldValue
End If
Next ctl
Private Sub cmdCancel_Click()
Dim ctl As Control
For Each ctl In Me.Controls
If ctl.Type = acTextBox Or ctl.Type = acComboBox Or
ctl.Type = acCheckBox Then
ctl.Value = ctl.Tag
End If
Next ctl
End Sub
When the form loads I get a type mismatch error.
When I click cmdCancel button I get error "object does not support
property or method"
How do I resolve this?
Thanks
Message #13 by "Howard Stone" <ququmber@h...> on Thu, 23 May 2002 07:56:43
|
|
The database has a main form and two subforms.
Private Sub Form_Activate()
Dim ctl As Control
For Each ctl In Me.Controls
Select Case ctl.ControlType
Case acTextBox, acComboBox, acCheckBox, acCustomControl
ctl.Tag = ctl.Value
End Select
Next ctl
End Sub
The above code uses the Form_Activate procedure. If I use the Form_Load
each time the form Loads I get an error (#13) "Type mismatch". The error
does not occur with the load event.
The above code is also attached to the Form_Load event of each subforms
(note no "Type mismatch" error here)
The undo comand button is attached to the main form and has the following
code
Private Sub cmdCancel_Click()
Dim ctl As Control
For Each ctl In Me.Controls
Select Case ctl.ControlType
Case acTextBox, acComboBox, acCheckBox
ctl.Value = ctl.Tag
End Select
Next ctl
End Sub
When this button is clicked I get error "You cant assign a value to this
object". Error #2448.
I hope this gives enough info to resolve the problem.
Message #14 by "George Oro" <george@c...> on Mon, 27 May 2002 09:52:32 +0400
|
|
John / Howard,
Actually I tried the below code because I need it also, one thing I noticed why Howard having "Type mismatch" its because maybe? one
of the control is Null value. If that's the case, how to consider those control with null value?
Error:" You cant assign a value to this object". Error #2448. (NO IDEA!)
Please let me know guys if found the solution on the above matters.
Cheers,
George
-----Original Message-----
From: Howard Stone [mailto:ququmber@h...]
Sent: Thursday, May 23, 2002 7:57 AM
To: Access
Subject: [access] Re: undo procedure
The database has a main form and two subforms.
Private Sub Form_Activate()
Dim ctl As Control
For Each ctl In Me.Controls
Select Case ctl.ControlType
Case acTextBox, acComboBox, acCheckBox, acCustomControl
ctl.Tag = ctl.Value
End Select
Next ctl
End Sub
The above code uses the Form_Activate procedure. If I use the Form_Load
each time the form Loads I get an error (#13) "Type mismatch". The error
does not occur with the load event.
The above code is also attached to the Form_Load event of each subforms
(note no "Type mismatch" error here)
The undo comand button is attached to the main form and has the following
code
Private Sub cmdCancel_Click()
Dim ctl As Control
For Each ctl In Me.Controls
Select Case ctl.ControlType
Case acTextBox, acComboBox, acCheckBox
ctl.Value = ctl.Tag
End Select
Next ctl
End Sub
When this button is clicked I get error "You cant assign a value to this
object". Error #2448.
I hope this gives enough info to resolve the problem.
Message #15 by "John Ruff" <papparuff@c...> on Mon, 27 May 2002 06:52:37 -0700
|
|
You can test for null.
If not isnull(ctl.value) then
Ctl.tag=ctl.value
endif
John Ruff - The Eternal Optimist :-)
Always Looking for a Contract Opportunity
xxx.xxx.xxxx
9306 Farwest Dr SW
Lakewood, WA 98498
-----Original Message-----
From: George Oro [mailto:george@c...]
Sent: Sunday, May 26, 2002 10:53 PM
To: Access
Subject: [access] Re: undo procedure
John / Howard,
Actually I tried the below code because I need it also, one thing I
noticed why Howard having "Type mismatch" its because maybe? one
of the control is Null value. If that's the case, how to consider those
control with null value?
Error:" You cant assign a value to this object". Error #2448. (NO
IDEA!)
Please let me know guys if found the solution on the above matters.
Cheers,
George
-----Original Message-----
From: Howard Stone [mailto:ququmber@h...]
Sent: Thursday, May 23, 2002 7:57 AM
To: Access
Subject: [access] Re: undo procedure
The database has a main form and two subforms.
Private Sub Form_Activate()
Dim ctl As Control
For Each ctl In Me.Controls
Select Case ctl.ControlType
Case acTextBox, acComboBox, acCheckBox, acCustomControl
ctl.Tag = ctl.Value
End Select
Next ctl
End Sub
The above code uses the Form_Activate procedure. If I use the Form_Load
each time the form Loads I get an error (#13) "Type mismatch". The
error
does not occur with the load event.
The above code is also attached to the Form_Load event of each subforms
(note no "Type mismatch" error here)
The undo comand button is attached to the main form and has the
following
code
Private Sub cmdCancel_Click()
Dim ctl As Control
For Each ctl In Me.Controls
Select Case ctl.ControlType
Case acTextBox, acComboBox, acCheckBox
ctl.Value = ctl.Tag
End Select
Next ctl
End Sub
When this button is clicked I get error "You cant assign a value to this
object". Error #2448.
I hope this gives enough info to resolve the problem.
Message #16 by "Amy Wyatt" <amyw@c...> on Tue, 28 May 2002 21:58:37
|
|
If you want a safer less frustrating procedure try using unbound fields
for the edit process. Since you are limiting it to one record you can
easily unbind the controls or make a 'twin' form the opens and then you
fill in the values on the open of this unbound form. It the click Save you
save the changes to the actual table if the click Cancel you can just
close the form and open the bound form or clear the fields and rebind the
form (depending on how you start out).
I have done it both ways and if I don't have to deal with more than one
record, I much perfer the unbound method.
Otherwise, when using subforms, you would be best to send a warning when
they leave the subform stating that any changes they have made will be
made permanent.
Another thing you can try, although it is not consistant when it works and
when it doesn't, is to so a send key of the ESC key twice to undo changes.
Again, this won't work once you leave the subform and the data is comitted.
Good luck.
Amy
> I have a command button named cmdFilter on a form that when clicked
f> ilters a form and bring up one record only that allows the user to edit
t> his record.
> I want to put a second button named cmdCancel that will undo any changes
m> ade before saving record.
> What procedure could I use with this command button.
>
T> hanks
|
|
 |