Not sure I understand why you need this, surely you are able to tell which command is used in your own code, unless the same peice of code contains the both and is dependant on some parameter. In which case maybe set a variable to one of two values depending on which code is executed.
Yes, I already thought about using a variable. It would be less house-keeping to check the status of the form, however.
The reason for checking whether the form was opened in new or edit mode is to make certain controls visible and other controls locked.
As an example, when the form is opened acFormNew, then some of the form's controls are visible = false. On the other hand, when the form is opened acFormEdit, the controls that are not visible are changed to visible. Also other controls on the form (in acFormEdit) mode will have their property for locked set to yes.
Perhaps you could use the openargs parameter of the docmd.openform command. Pass different arguments to the called form with each docmd.openform. That way your code in the called form can take appropriate actions depending on the argument passed.
Hmmm... have you tried setting the values based on the Primary key's value? If the form opens a new record your primary key should be a null value (because its new). So on your form's "On Current" event you could run something like this:
If IsNull(Me!PrimaryKeyFieldName) Then
Me!TextBox1.Visible = False
Me!TextBox2.Visible = False
Else
Me!TextBox1.Visible = True
Me!TextBox2.Visible = True
End If
If you need to show these controls at somepoint when the record is being typed in then you would set the controls' visibility properties on another textbox's "After Update" event.
But thats just my 2 cents worth...
jbehrne
If at first you don't succeed, call in an airstrike. - Murphy's Laws of Combat Operations
Yep, I already considered openargs. But again, I am hoping that a forms property exists that I could check. I haven't ruled out the use of openargs, however.
I like the idea of checking the primary key. I'm gonna try it and the openargs and decide which works best with our application. Thanks to all who posted in this thread.
This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
By continuing to use this site, you are consenting to our use of cookies.