So, I recently worked with a large access database, and I was thinking about how to start refactoring. One of the main difficulties of refactoring is that most forms are based on data in other forms.
The way this is currently being done is as follows:
Form1has a button on it called Cmd1that opens a new form ( DoCmd.OpenForm "Form2") and pre-populates some form controls using Forms!Form2.Control = Me.Control. When closing, Form2data is returned on Form1, calling Forms!Form1.Control = Me.Control.
This presents a problem if I want to change the names of both forms, or which form opens the popup. It also requires that both forms be open, which you cannot rely on when you cannot use modal pop-up forms, because users want to be able to share between forms.
I see 5 methods of passing values back and forth between forms, each with its own problems, and I was wondering what was recommended.
- The method is already installed, as described above.
- Using OpenArgs - makes many values complicated, since you need to parse a string and be unidirectional.
- Using global variables - this will mean a lot of variables in a random module and is a nightmare to review.
- Storing values that must be passed between forms in a temporary table.
Public master As Form
Private Sub Form_Load()
Set master = Screen.ActiveForm
Me.Control = master.Control
End Sub
, , master.master.control, , .
, ?