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. |
|
|
Thread Tools | Display Modes |
#1
|
|||
|
|||
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
|
|||
|
|||
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
|
|||
|
|||
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
|
|||
|
|||
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 | |
|
|