Form On Open event, except not exactly

R

rb608

I have a form with a command button that opens a second form and
populates it with data from the initial form. That part is fine.
What I want to do is use that data in an On Open event (or something)
that will execute *after* the data is loaded by the first procedure.

Specifically, the second form should display an image based on a path
and filename concatenated from the first form's data :
Forms!PhotoData!imgFrame1.Picture = strImagePath

It all works fine using a command button on the second form; but that
requires loading a default image and a manual click to display the
intended image. I want the desired strImagePath image to load
automatically when the form opens.

There's a sequence problem, however. I can't transfer the data to the
second form before opening it (DoCmd.OpenForm "PhotoData"); but I
can't create the strImagePath from that data until after the form is
opened, so I can't create the image path string in an On Open event
procedure.

I know there has to be another way to do this. Suggestions? Anybody
want to make me slap my forehead and say, "D'oh!"?

TIA,
Joe
 
B

BRC

I have a form with a command button that opens a second form and
populates it with data from the initial form. That part is fine.
What I want to do is use that data in an On Open event (or something)
that will execute *after* the data is loaded by the first procedure.

Specifically, the second form should display an image based on a path
and filename concatenated from the first form's data :
Forms!PhotoData!imgFrame1.Picture = strImagePath

It all works fine using a command button on the second form; but that
requires loading a default image and a manual click to display the
intended image. I want the desired strImagePath image to load
automatically when the form opens.

There's a sequence problem, however. I can't transfer the data to the
second form before opening it (DoCmd.OpenForm "PhotoData"); but I
can't create the strImagePath from that data until after the form is
opened, so I can't create the image path string in an On Open event
procedure.

I know there has to be another way to do this. Suggestions? Anybody
want to make me slap my forehead and say, "D'oh!"?

TIA,
Joe

I am far from expert, but it seems you could pass the path with
"openargs' method. in what ever statement you are using to open second
form. Hope this helps
 
D

Dennis

So create a module, and in it, define some PUBLIC variables in which to store
values during the On Open event. Then, at a point of your choosing, simply
call a private (or public for that matter) sub, and use those variables to
fetch what you need.
 
B

BRC

Sorry about my earlier post, i didn't read your original close enough.
I think what you want to do could be done if you put your code in
form2's activate event. See vb help for details on when it occurrs.
 
R

rb608

So create a module, and in it, define some PUBLIC variables in which to store
values during the On Open event. Then, at a point of your choosing, simply
call a private (or public for that matter) sub, and use those variables to
fetch what you need.


I sort of took a blunt instriument approach along those same lines. I
just put a duplicate subroutine in the procedure that opens the form
so that it forces the filename into the control as part of opening the
form.

Tx.
 

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