Using a form for more than one use

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.
 
D

Douglas J. Steele

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
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top