Add and Edit Form

  • Thread starter Thread starter Mark S
  • Start date Start date
M

Mark S

In a database I inherited, there is separate Edit form and Add form for
single record adds or edits. Since the forms are similar, I assume the
better way to do this would be with a single form and use the DataMode in the
OpenForm Method.

There are some minor differences between the forms with some button
differences and a few fields that don't need to be seen on a new record.

Is my assumption correct that it is normally best to use a single form for
Edit and Add? How do you test to see how a form was opened (what DataMode is
it in)? Or is it better to send a flag with OpenArgs?

My thought is once I test for how the form was opened, just set the controls
I want as Visible (or not). Is it best to do this in the code that opened
the data entry form or in the On Open (or other) event in the data entry form
itself.

I hope it makes sense what I am trying to do. If I am not asking the right
questions please make any suggestions.
 
Mark said:
In a database I inherited, there is separate Edit form and Add form for
single record adds or edits. Since the forms are similar, I assume the
better way to do this would be with a single form and use the DataMode in the
OpenForm Method.

There are some minor differences between the forms with some button
differences and a few fields that don't need to be seen on a new record.

Is my assumption correct that it is normally best to use a single form for
Edit and Add? How do you test to see how a form was opened (what DataMode is
it in)? Or is it better to send a flag with OpenArgs?

My thought is once I test for how the form was opened, just set the controls
I want as Visible (or not). Is it best to do this in the code that opened
the data entry form or in the On Open (or other) event in the data entry form
itself.


Using a single form is usually better because of it reduces
the problems of maintaining two very similar forms. Making
some controls invisible is a simple enough that won't make a
mess of the form's logic.

You can check the form's DataEntry property to see if the
form was opened in add mode.

It is almost always best to have a form manipulate itself.
There can be timing issues when trying to do things to forms
right after the OpenForm line. Besides, doing it within the
form isolates knowledge of the form's control names, etc.
 
Thanks. The Data Entry property is what I was looking for. Don't know why I
couldn't find it. And thanks for taking the time to confirm my thoughts.
I'm no programmer, but somehow managed to get into this years ago. Now
everytime there's an MS Office problem of any kind, I get called.
 
Back
Top