By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
426,179 Members | 2,175 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 426,179 IT Pros & Developers. It's quick & easy.

Current event fires twice - how to excute code just once?

P: n/a
I'm surprised that the Current event of forms always fires twice
(Access XP).
I have quite a lot of processing done in the current event, how to make
the code run just once?

Thanks

Mar 23 '06 #1
Share this Question
Share on Google+
3 Replies


P: n/a
<do******@hotpop.com> wrote in message
news:11**********************@g10g2000cwb.googlegr oups.com...
I'm surprised that the Current event of forms always fires twice
(Access XP).
I have quite a lot of processing done in the current event, how to make
the code run just once?


I have never noticed that happening on any of my forms. Perhaps your actual
code is somehow calling itself or calling another procedure/function that is
producing the second run.

If you have nothing in your current event but a MsgBox() do you see it displayed
twice?

--
I don't check the Email account attached
to this message. Send instead to...
RBrandt at Hunter dot com
Mar 23 '06 #2

P: n/a

<do******@hotpop.com> wrote in message
news:11**********************@g10g2000cwb.googlegr oups.com...
I'm surprised that the Current event of forms always fires twice
(Access XP).
I have quite a lot of processing done in the current event, how to make
the code run just once?

Thanks


As Rick says, this doesn't sound like any known issue - more likely your
coding. If you created a new blank form based on a table and pasted in:

Dim m_lngCount As Long

Private Sub Form_Current()
m_lngCount = m_lngCount + 1
Me.Caption = CStr(m_lngCount)
End Sub

You would see from the caption that you were going up in ones, not twos, so
the current event must only be firing once.

Is there some form of re-query or re-setting the form's recordsource?
Mar 23 '06 #3

P: n/a
Bri

do******@hotpop.com wrote:
I'm surprised that the Current event of forms always fires twice
(Access XP).
I have quite a lot of processing done in the current event, how to make
the code run just once?


Are you are referring to it running twice when a Form (or is it a
subForm) first opens? I've seen this and it seems that there is nothing
you can do to stop it from running twice, but you can put in a test to
see if it is the first time or subsequent times. What seems to happen is
that the Current Event fires when the Form first opens, before the
recordsource is loaded, and then again after it has the recordset and
arrives on the first record. Unfortunately any test for the existence of
the recordsource (or its clone) produces an error if it doesn't yet have
one. You could trap that error so it doesn't get displayed. I don't know
off the top of my head what circumstances actually cause it, but I have
definitely had it happen to me too.

--
Bri

Mar 24 '06 #4

This discussion thread is closed

Replies have been disabled for this discussion.