A Microsoft Office (Excel, Word) forum. OfficeFrustration

If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

Go Back   Home » OfficeFrustration forum » Microsoft Access » Using Forms
Site Map Home Register Authors List Search Today's Posts Mark Forums Read  

Calling private sub from different form



 
 
Thread Tools Display Modes
  #1  
Old June 9th, 2004, 02:50 PM
Simon
external usenet poster
 
Posts: n/a
Default Calling private sub from different form

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!
  #2  
Old June 9th, 2004, 05:18 PM
Sandra Daigle
external usenet poster
 
Posts: n/a
Default Calling private sub from different form

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.


Simon wrote:
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!



  #3  
Old June 10th, 2004, 12:26 PM
Simon
external usenet poster
 
Posts: n/a
Default Calling private sub from different form

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.


Simon wrote:
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!



.

  #4  
Old June 10th, 2004, 04:26 PM
Sandra Daigle
external usenet poster
 
Posts: n/a
Default Calling private sub from different form

No problem - glad to help.

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


Simon wrote:
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.


Simon wrote:
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!



.



 




Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Forum Jump


All times are GMT +1. The time now is 07:14 AM.


Powered by vBulletin® Version 3.6.4
Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 OfficeFrustration.
The comments are property of their posters.