Form Command Buttons

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

On one of my forms (frmMain) I want 2 command buttons. One that opens
another form (frmEmployees) in add mode and the same employee form in edit
mode. I have this figured out - just change the code that the wizard
creates. The only problem I have is, I want different command buttons on
both employee forms. Should I just copy the employee form and have 2 forms
(frmEmployees1 & frmEmployees2) and reference each form and put whatever
buttons I want on each form or is there another way to do this?

Thank you, Karen
 
You could toggle the visibility of different command buttons ...

Private Sub Form_Open(Cancel As Integer)

If Me.DataEntry Then
Me.Command4.Visible = True
Me.Command5.Visible = False
Else
Me.Command4.Visible = False
Me.Command5.Visible = True
End If

End Sub

Or you could use one button for two different purposes ...

Private Sub Command4_Click()

If Me.DataEntry Then
MsgBox "Doing something ..."
Else
MsgBox "Doing something else ..."
End If

End Sub

Private Sub Form_Open(Cancel As Integer)

If Me.DataEntry Then
Me.Command4.Caption = "Do Something"
Else
Me.Command4.Caption = "Do Something Else"
End If

End Sub

Or you could, as you say, use two different forms. It mostly depends on just
how many differences there are. If there are only a few, you'll likely be
better off with one form that behaves differently under different
conditions. If there are a lot, then you might be better off with two
separate forms.
 
Back
Top