Check if form is opened for edit or add

RexesOperator

Registered User.
Local time
Today, 10:42
Joined
Jul 15, 2006
Messages
604
I would like to set the properties of a control on a form based on if it is opened in edit or add mode.

For example I use one form for both editing and adding records (the mode is changed based on the command button that calls it). I have a command button on the form for searching records I created using the command button wizard. It's kind of pointless to have it active when there is no data to search for.

I'd like to have the form opened in add mode with the button either not enabled or not visible, but in edit mode have the button enabled or visible.

This isn't essential, but it would be nice to have.

I know one option is to have the form opened by DoCmd.OpenForm, but how would I control the add/edit mode using DoCmd?
 
You can use the DataMode portion of the Docmd to tell the form in general how to open or if you wish to be more specific use the OpenArgs of the DoCmd to pass info to the form being opened. You can then test the OpenArgs in the on load event of the form being opened, and set the various on form control Add/Edit properties accordingly.
 
Thank you - the DeCmd works perfectly!
 
I too think this is what I'm looking for. I would like to test if a form is opened in ADD or ReadOnly, then perform select operations accordingly -- something like:

If form in EDIT then
do this
Else
do that
end if


Thanks,
SKK
 
Try something like;

Code:
If Me.AllowEdits = True Then 
     Do some action
Else
     Do something else
End If
 
Ahh pretty simple -- thank you.

This will work for most cases but what if I want to test if the form is in ADD (new record)/ Is there a way to test for ADD, ReadOnly, etc.

SKK
 
I think I answered my question

If Me.NewRecord = True Then

Thanks again,
SKK
 
use
If Me.DataEntry Then ...
to test for Add mode.
 
apologies for reopening this old Thread,
but if I were to test for a form to be open as Read only, what would I test for ?

me.allowedits ?
 

Users who are viewing this thread

Back
Top Bottom