Form Load Event Occurs Twice

S

SpanishSage

Version 2000 or 2003
Trying to load a form with one unbound text box control (can't use a label
because the text is not selectable). It opens fine when run independently.
But it needs to open with a keyboard command invoked from a form that s
already running. This is when Load happens a second time.

There's a series of external functions that returns a string of information
from the database for text box; an input box takes an ID key to grab the
data. This is how it's known load is happening twice - the input box comes up
a second time. Before the second load starts the deactivate event fires for
no reason or a reason that can't be found.

Tried some work a rounds with Timer and setting a form variable to the time
type (it gets reset) , trapping the deactivate, but the end result is
always the same or worse.

Thanks
 
J

Jeanette Cunningham

Hi SpanishSage,
Try getting the value from the external functions before you fire the
command to open the form.
Save the value into a variable or hidden textbox on the form that is already
open.
Then open the form and let it read the value for its unbound text box from
the still open 'already open' form before you close it.


Jeanette Cunningham MS Access MVP -- Melbourne Victoria Australia
 
S

SpanishSage

Thanks Jeanette,

After a little more digging on some other forums, found a post that solved
the problem. Supposedly an implicit call was used to open the form,
Docmd.OpenFrom Form_FormToOpen.Name, this created a separate call to the form
class object. Even though "Option Explicit" was set in the calling form, an
error was never raised. Changed the syntax to Docmd.OpenFrom "FormToOpen" and
the problem went away.

Thought of but never tried a solution similar to yours, a little stubborn
that way because a version that was done stand alone worked perfectly. Really
don't want to add a lot of additional coding to what exists because of the
trouble it may be to maintain it. As is, any code that does exists was done
by the built in wizards. This interim solution solves the problem of having
to key in a finished product part number / serial number taken from a table
of product "components" used to build up an order (or in this case order
items).

My job isn't programming the database, but can leverage my ideas if
solutions can been shown that makes jobs a little more efficient without
disruption to the company operation. Maybe compensated in the future.

Should have mentioned that "function" is actually a class with several
embedded routines. As is, a string is exposed with the desired information to
fill the text box value. It's also not and may never be "perfect" because of
the underlying database design. It does eliminate some of the keying errors
associated with having to manually type out everything.
Used: ADO recordset (cloned disconnected) and multi-dimensional arrays.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top