recognising when form is opened in add mode

  • Thread starter Thread starter Andre C
  • Start date Start date
A

Andre C

is there a VBA way of telling if a form is opened in add or edit
mode. I want to make a particular control invisible if the form is
opened in add mode.
 
Forms have AllowAdditions, AllowEdits, AllowDeletions and Dataentry
properties that you can check.
 
Douglas, Those properties tell what can be, not what is.
I don't know if the OP has a situation where he does not know how the form
was opened, but for most normal cases, couldn't he just control that when he
opens the form using the OpenArgs?

When opening in Edit, for example, put "Edit" in the OpenArgs or "Add" for Add

Then in the Load Event of the form:

If Me.OpenArgs = "Edit" Then
Me.SomeControl.Visible = True
Else
Me.SomeControl.Visible = False
End If
 
My original answer was going to be to use OpenArgs as well, but when I
looked a little closer at the properties of the Form object, I thought it
might be possible to use them. However, I didn't test, so I can't offer
specific advice on how to use them, so I'll concur with your suggestion.
 
Back
Top