Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Westi on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

How set an option value back to his old value? 1

Status
Not open for further replies.

checkOut

Technical User
Oct 17, 2002
153
NL
I have an optionbox with 4 possibilities.
1 possibility is tricky so I warned the user and give them a way to cancel their choice. I have the following code:

Private Sub KaderOnderhoud_AfterUpdate()
tempValue = Me.KaderOnderhoud
End Sub

Private Sub KaderOnderhoud_BeforeUpdate(Cancel As Integer)
Dim check_flag As Boolean
check_flag = True
If tempValue = 1 Then
If Not Bevestigen("Weet u zeker dat u het abonnement wilt veranderen?" & vbNewLine & _
"Dit kan gevolgen hebben voor de eventueel reeds ingevoerde " & _
"onderhoudsabonnementen.") Then
check_flag = False
cancel = true
End If
End If
If check_flag Then
If Me.wb_OHvalue = 1 Then
Me.subFrmOHbijWerkbon.Visible = True
Else
Me.subFrmOHbijWerkbon.Visible = False
End If
End If
End Sub
the problem is, the program asked the question. But no matter what's the users interaction (true/false) the value becomes the new value.

anybody understand what's happen?
Thnx in advance,
gErard
 
thnx for ur quick reply, Paul

I'm afraid that me.undo reset ALL me changes in the form and that's not what I want...

Gerard
 
No, you need

KaderOnderhoud.Undo



But even then I can't see that the code will work

You are using
If tempValue = 1
without a Dim tempValue anywhere in sight
you are using it in the Before Update event
yet you don't get round to setting it to the control's value until the AFTER_update event.

And in actual fact you don't need it at all.


Try this

Private Sub KaderOnderhoud_BeforeUpdate(Cancel As Integer)
Dim check_flag As Boolean
check_flag = True
If KaderOnderhoud = 1 Then ' ( You don't need Me. either )
If Not Bevestigen("Weet u zeker dat u het abonnement wilt veranderen?" & vbNewLine & _
"Dit kan gevolgen hebben voor de eventueel reeds ingevoerde " & _
"onderhoudsabonnementen.") Then
check_flag = False
cancel = true
KaderOnderhoud.Undo
End If
End If
If check_flag Then
If Me.wb_OHvalue = 1 Then
Me.subFrmOHbijWerkbon.Visible = True
Else
Me.subFrmOHbijWerkbon.Visible = False
End If
End If
End Sub




'ope-that-'elps.


G LS
accessaceNOJUNK@valleyalley.co.uk
Remove the NOJUNK to use.

Please remember to give helpful posts the stars they deserve!
This makes the post more visible to others in need! :-D

 
thnx mr Smudge, ur right.
I set the tempvalue in the form_load, I need the tempvalue while I have to know what the value WAS and not what the value BECOMES.

I just tried this way but changed the cancel = true in kaderonderhoud.undo,
as I can see I need them both ;)
 
Yes you need them BOTH because they actually do two different things.

Cancel stops the process that was about to update the .PreviousValue of the control And will stop the After_Update event from occuring as well.

controlName.Undo changes the displayed contents of the control back to what it was before the user started 'fiddling'.



'ope that 'elps you understand what's going on.



G LS
accessaceNOJUNK@valleyalley.co.uk
Remove the NOJUNK to use.

Please remember to give helpful posts the stars they deserve!
This makes the post more visible to others in need! :-D

 
Get a star, I'm proud of ur knowledge,
yes, now I understand what happens,
before_update was a strange event for me, it never done what I want and I always take a way around it, but from now I can use it in a better way
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top