Using a form for more than one use

  • Thread starter Thread starter TeeSee
  • Start date Start date
T

TeeSee

I would like to use an existing form "frmMaterialMasterADD" for two
different applications within the same DB. The path to the form comes
from two different CmdButtons. The bound information and format would
not change but I would like to place/show/activate a CmdButton on one
showing of the form and not show it on the other. Where and how would
I code this?

Thanks as always.
 
Easiest approach would be to pass something as the OpenArgs parameter and
use that to determine whether or not to show the command button.

Something like:

DoCmd.OpenForm "NameOfForm", acNormal, OpenArgs:="Case1"

and

DoCmd.OpenForm "NameOfForm", acNormal, OpenArgs:="Case2"

then in the Load event of the form:

Private Sub Form_Load()

If IsNull(Me.OpenArgs) = False Then
Select Case Me.OpenArgs
Case "Case1"
Me!MyCommandButton.Visible = False
Case "Case2"
Me!MyCommandButton.Visible = True
End Select
End If

End Sub
 
Back
Top