Stop an event from running

  • Thread starter Thread starter LMB
  • Start date Start date
L

LMB

Hi Guys,

I have the event procedure below to run on a control on my form but I don't
think I want to use it after all but don't want to delete it, how do I
change it so it won't run?

Thanks, Linda

Private Sub RdBlksID_AfterUpdate()

If Me.RdBlksID = 8 Then
Me.Other_Desc.Visible = True
Me.Other_Desc_Label.Visible = True
Else
Me.Other_Desc.Visible = False
Me.Other_Desc_Label.Visible = False
End If

End Sub
 
Private Sub RdBlksID_AfterUpdate()
Exit Sub
If Me.RdBlksID = 8 Then
Me.Other_Desc.Visible = True
Me.Other_Desc_Label.Visible = True
Else
Me.Other_Desc.Visible = False
Me.Other_Desc_Label.Visible = False
End If
End Sub
 
Another way is to delete "[Event Procedure]" in the "On After Update"
Property of the Control "RdBlksID".

HTH
Van T. Dinh
MVP (Access)
 
Gee,

That sure was hard! Now since I am brand new to this code stuff, if I want
to remind myself later on how to get it to work again, can I type the line
below in front or behind it?

'take this line out to run subroutine

Thanks,
Linda
 
Yea, but I may want to use it after all and it took a lot of time for me to
get it so I didn't want to lose it.

Thanks,
Linda

Van T. Dinh said:
Another way is to delete "[Event Procedure]" in the "On After Update"
Property of the Control "RdBlksID".

HTH
Van T. Dinh
MVP (Access)



LMB said:
Hi Guys,

I have the event procedure below to run on a control on my form but I don't
think I want to use it after all but don't want to delete it, how do I
change it so it won't run?

Thanks, Linda

Private Sub RdBlksID_AfterUpdate()

If Me.RdBlksID = 8 Then
Me.Other_Desc.Visible = True
Me.Other_Desc_Label.Visible = True
Else
Me.Other_Desc.Visible = False
Me.Other_Desc_Label.Visible = False
End If

End Sub
 
You can type that line at the end of the Exit Sub line, or you can insert it
as a new line above the Exit Sub line.
 
I didn't advise you to delete the code!

All you need to do is to delete the phrase "[Event Procedure]" (literally)
in the "On After Update" Property row of the Properties window for the
Control "RdBlksID".

The code stays in the Module but it will not be called as nothing is set in
the "On After Update" Property.

I prefer this way rather than calling / executing the Event Procedure code
but then exiting it straight away (I claim my way takes 0 microsec to
execute and Ken's way take a non-zero microsec to execute so my way is more
efficient - <g> Sorry, Ken).

HTH
Van T. Dinh
MVP (Access)
 
Oh an wow, that sure is a lot faster! <g> I thought if I deleted the event
procedure the code would be gone. If I do that, how do I remember it's
there later and how do I use it again if I need it? Is there a place in
access to keep a log or make notes to yourself?

Thanks,
Linda


Van T. Dinh said:
I didn't advise you to delete the code!

All you need to do is to delete the phrase "[Event Procedure]" (literally)
in the "On After Update" Property row of the Properties window for the
Control "RdBlksID".

The code stays in the Module but it will not be called as nothing is set
in
the "On After Update" Property.

I prefer this way rather than calling / executing the Event Procedure code
but then exiting it straight away (I claim my way takes 0 microsec to
execute and Ken's way take a non-zero microsec to execute so my way is
more
efficient - <g> Sorry, Ken).

HTH
Van T. Dinh
MVP (Access)


LMB said:
Yea, but I may want to use it after all and it took a lot of time for me to
get it so I didn't want to lose it.

Thanks,
Linda
 
Van T. Dinh said:
I prefer this way rather than calling / executing the Event Procedure code
but then exiting it straight away (I claim my way takes 0 microsec to
execute and Ken's way take a non-zero microsec to execute so my way is
more
efficient - <g> Sorry, Ken).

< g > That's ok... I like my method better, though, only because I then
don't go back in a few months and see that procedure sitting there without
being used and ask, "Hmm... I wonder why I left that there? Oh well, let's
clean up." and then I delete it. < g >

As one gets old, one uses all the memory tricks available to one! < BG >
 
Ken Snell said:
< g > That's ok... I like my method better, though, only because I then
don't go back in a few months and see that procedure sitting there without
being used and ask, "Hmm... I wonder why I left that there? Oh well, let's
clean up." and then I delete it. < g >

As one gets old, one uses all the memory tricks available to one! < BG >

I will probably go with your method Ken..we must be around the same age
because I know I would forget and I like to clean up too...which sometimes
is a big mistake. Now, how would you know if the procedure is not being
used?

Thanks,
Linda
 
The Exit Sub as the first line of code tells me that I have specifically
bypassed that routine. And a comment line there (stating that the procedure
isn't being used right now) too would tell me that.

--

Ken Snell
<MS ACCESS MVP>
 
Well ... you don't have to remember.

If for some reason, you need to run some code on the AfterUpdate Event of
"RdBlksID", you simply select "[Event Procedure]" (literally) and click the
"Build" button, Access will take you right back to the existing/held
procedure code.

Of course, I have a header block (comments) on every bit of codes I write so
I put comments why I keep it there if it is not being used.

OTOH, the main point of my previous post is to correct your misunderstanding
that I advised you to delete the code. I did read your original question
and answered it appropriately.

HTH
Van T. Dinh
MVP (Access)
 
I am sure you use dated comments for history of amendments to the procedure
like:

' dd/mm/yyyy Not used but code held just in case I get too old to
reconstruct the code.

<g>

Cheers
Van T. Dinh
MVP (Access)

P.S. I am ancient but I hope the grey matter will work a bit longer yet.
 
Van T. Dinh said:
I am sure you use dated comments for history of amendments to the procedure
like:

' dd/mm/yyyy Not used but code held just in case I get too old to
reconstruct the code.

<g>


Histories of amendments? Mmmm, no.... I never remember to do that.
 
Back
Top