Calling private sub from different form

S

Simon

I have a main record form (A) from which a user can
retrieve a record by typing in an ID and
clicking 'Retieve'. The user could also click search and
a second form (B) pops up to provide a list of all records
which they can filter using a selection of drop-down
boxes. Currently, when a user selects a record from B, B
is hidden and then code similar to that behind A.Retrieve
runs (I'm pushing and pulling all data, not using Access
real-time form accessing by the way). What I would like
to do is simply return the ID selected to A and then call
the private sub Retieve_Click in A from B (thus meaning
that I only have one version of the Retrieve code to keep
up-to-date) ... BUT ... I don't want to use acDialog as
that will involve closing B rather than hiding it and thus
the user's search preferences will be lost. Any ideas how
to call a private sub on A from code in B??!

Many thanks in advance,

Simon

P.S. Sorry for the essay!
 
S

Sandra Daigle

Hi Simon,

I'd still recommend using acDialog - you don't have to close the form (b).
Just set its visible property to false. This will hide the form and return
control to the code which opened it.

Regardless, to run Retrieve_Click in A just make it a Public sub. This makes
it available as a method of the form so to execute it you would say:

forms!frmB.Retrieve_Click
 
S

Simon

Thank you for this. Both reasonably obvious I just hadn't
thought to try either!

Also, apologies for the double-post. Will remember that
in future.

Simon
-----Original Message-----
Hi Simon,

I'd still recommend using acDialog - you don't have to close the form (b).
Just set its visible property to false. This will hide the form and return
control to the code which opened it.

Regardless, to run Retrieve_Click in A just make it a Public sub. This makes
it available as a method of the form so to execute it you would say:

forms!frmB.Retrieve_Click

--
Sandra Daigle [Microsoft Access MVP]
Please post all replies to the newsgroup.

I have a main record form (A) from which a user can
retrieve a record by typing in an ID and
clicking 'Retieve'. The user could also click search and
a second form (B) pops up to provide a list of all records
which they can filter using a selection of drop-down
boxes. Currently, when a user selects a record from B, B
is hidden and then code similar to that behind A.Retrieve
runs (I'm pushing and pulling all data, not using Access
real-time form accessing by the way). What I would like
to do is simply return the ID selected to A and then call
the private sub Retieve_Click in A from B (thus meaning
that I only have one version of the Retrieve code to keep
up-to-date) ... BUT ... I don't want to use acDialog as
that will involve closing B rather than hiding it and thus
the user's search preferences will be lost. Any ideas how
to call a private sub on A from code in B??!

Many thanks in advance,

Simon

P.S. Sorry for the essay!


.
 
S

Sandra Daigle

No problem - glad to help.

--
Sandra Daigle [Microsoft Access MVP]
Please post all replies to the newsgroup.

Thank you for this. Both reasonably obvious I just hadn't
thought to try either!

Also, apologies for the double-post. Will remember that
in future.

Simon
-----Original Message-----
Hi Simon,

I'd still recommend using acDialog - you don't have to close the
form (b). Just set its visible property to false. This will hide the
form and return control to the code which opened it.

Regardless, to run Retrieve_Click in A just make it a Public sub.
This makes it available as a method of the form so to execute it you
would say:

forms!frmB.Retrieve_Click

--
Sandra Daigle [Microsoft Access MVP]
Please post all replies to the newsgroup.

I have a main record form (A) from which a user can
retrieve a record by typing in an ID and
clicking 'Retieve'. The user could also click search and
a second form (B) pops up to provide a list of all records
which they can filter using a selection of drop-down
boxes. Currently, when a user selects a record from B, B
is hidden and then code similar to that behind A.Retrieve
runs (I'm pushing and pulling all data, not using Access
real-time form accessing by the way). What I would like
to do is simply return the ID selected to A and then call
the private sub Retieve_Click in A from B (thus meaning
that I only have one version of the Retrieve code to keep
up-to-date) ... BUT ... I don't want to use acDialog as
that will involve closing B rather than hiding it and thus
the user's search preferences will be lost. Any ideas how
to call a private sub on A from code in B??!

Many thanks in advance,

Simon

P.S. Sorry for the essay!


.
 

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