How to use a search form by launching it from different forms? (1 Viewer)

amorosik

Member
Local time
Today, 04:05
Joined
Apr 18, 2020
Messages
518
I have a procedure for administration and therefore the usual screens for articles, prices, invoices, etc.
Some search forms can be launched from different forms, for example the form frmArticoliCerca can be launched both from frmFatture and from frmArticoli and from frmClienti
I do not know in advance which forms could launch the frmArticoliCerca and therefore I would not like to insert specific references to the calling form in the frmArticoliCerca code, because in the future the frmArticoliCerca could also be launched from other points and I would not like to modify the code every time

The question is: how to allow the use of frmArticoliCerca from multiple forms, passing parameters from the calling form to the search form and vice versa?
 
Some Options:
1) pass calling form name to frmArticoliCerca with OpenArgs
2) pass other info to frmArticoliCerca with OpenArgs
3) calling forms set global variables or TempVars that are available anywhere
 
Other Options
4) If you open the pop up and you did not Use ACDialog then then can set a property directly without open args. This gives an advantage in passing actual objects vice names.
if the Pop up has a property or variable then you can set that directly
Example in pop up form "rmArticoliCerca" you set a module level variable (I would create a property)
Public CallingForm as Access.Form
then after you open the popup form you can set the value of the Calling form
docmd.openForm "rmArticoliCerca"
forms("FrmArticoliCerca").callingform = Me
This will not work if you open the pop up ACDIALOG
In certain cases this can be simpler than open args. With open args you have to write code in the called form. This can get difficult when you might want to pass multiple things.
 
<clip>
This can get difficult when you might want to pass multiple things.
That's why in Northwind 2 Developer Edition we pass name/value pairs via OpenArgs, which makes it self-describing. See the use of StringToDictionary .
There is also a YouTube video about the String functions.
 

Users who are viewing this thread

Back
Top Bottom