473,698 Members | 2,246 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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

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
3 5674
<do******@hotpo p.com> wrote in message
news:11******** **************@ g10g2000cwb.goo glegroups.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

<do******@hotpo p.com> wrote in message
news:11******** **************@ g10g2000cwb.goo glegroups.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
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 thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

3
3308
by: Matt | last post by:
Hello, I just don't get it. I have a simple webform1.aspx page, when loaded for the first time, the load even fires which is fine. In webform1.aspx i have a button that has a onclick event, and in this event i do a response.redirect to webform2.aspx page. However on the onclick event of the button, the Load event for webform1.aspx is loaded again! Then the redirection is done!
6
2843
by: Michael Johnson Jr. | last post by:
I am trying to handle a button click event, which updates a web control table with data. The button is dynamically created in the table itself. When I call updateTable() in the Page_Load the new data from the button is not available at this time as to allow the table to properly update. So basically, I need to call UpdateTable() twice, once from page load and once from button. This causes problems with my application, and I was trying...
7
2099
by: Jay Douglas | last post by:
Hello all, I have a asp.net page that creates a pdf on the fly and sends the pdf down to the browser. When calling the page up in IE the Page_Load event is fried twice. This doesn't happen with mozilla, just IE. This is a big problem because the PDF can be 20+ MB in size and is causing some serious performance issues. Writing the PDF to the filesystem then a redirect is not an option. I was wondering if anybody has any input on how...
1
2648
by: Bill Manring | last post by:
The startup page for my ASP.NET application is an HTML frames page with two frames. This seems to cause the Session_Start event in the Global.asax file to fire twice. When I change the startup page to an ordinary aspx page, the event only fires once. I would like to run some concurrent license checking code when the Session_Start event fires, so I either need to figure out how to stop it from firing twice or to figure aout a way to...
3
2756
by: RR | last post by:
I have a button on a form (form A) that opens another form. The form that opens (form B) has a listbox that is populated with a call to a function in the "on current" event. When form B with the listbox has a query listed as the data source, it works fine. In this case, the button on form A sets the record source for form B to one of several queries, depending on what is selected in a combobox on form A. When Form B first opens, an...
3
3585
by: Techsatish | last post by:
how to make a mouseup event called only once during a double click event? here double click is made on a tree node in a tree control. I have the code inside mouseup event....in runtime the mouseup is called twice for the mouse double click over the selected tree node. I want mouseup event to be called onece Any ideas?
5
6988
by: christianlott1 | last post by:
I admit my form is pretty complex and may need a total overhaul - I have two subforms synchronized on a form through an unbound text box. When I enter a new record in the second subform it used to complain about nulls and then about 'can't repeat an index'. To solve this I wrote code on the main form's subform enter event (I'm surprised I found it. I must have spent an hour trying to program the enter and exit events from the subform...
0
1603
by: manywolf | last post by:
I have an aspx page that fires the page load event twice for every load. I tried every fix that was suggested in all the posts on this and other forums. None changed the behavior. After one post that suggested they had an img tag with src="", I decided to look for instances of "src" and one by one start removing that code to see if it changed anything. Below is the one that, when I removed it, although it broke the flash menus and header, solved...
3
1564
by: =?Utf-8?B?QmFycnkgR2lsYmVydA==?= | last post by:
I have a class that raises events that downstream objects subscribe to. In one case, after destroying the object, the event seems to still get handled in a subscriber object. So I instantiate an object and the event fires correctly. Then I destroy the object and instantiate another instance and the subscriber event handler get hit twice. I've tried using IDisposible and also using GC.Collect, but it didn't seem to help. I've also tried...
0
8674
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
8603
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
9157
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
9027
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
8895
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
7725
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
0
5860
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
4619
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
3046
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.