Changing form properties from VBA code

S

Stephen @ ZennHAUS

Hi Guys and Gals

I know this is probably a really simple thing to do, but I want to change
the properties of an Access form from code. The property I want to change
expressly is DataEntry. Because I would like to use the same form for "data
entry only" as I do for viewing and editing records. Alternatively, if
anyone knows a better way to deal with something like this. Ultimately, I
would also like to be able to change the DataSource property as well
depending on how the form is opened.

Cheers

Stephen @ ZennHAUS
 
S

Stefan Hoffmann

hi Stephen,
I know this is probably a really simple thing to do, but I want to
change the properties of an Access form from code. The property I want
to change expressly is DataEntry.
What have you tried so far?
Because I would like to use the same
form for "data entry only" as I do for viewing and editing records.
Alternatively, if anyone knows a better way to deal with something like
this.
While this is always possible, I'd prefer a split into an entry form and
an edit/view form due to these considerations:

- Separation of Concerns:
When the complexity of an application grows, you normally have to apply
different (business) rules for data entry and data modification. Using
one form makes it sometimes difficult to maintain.

- dialog guided input:
I've seen a lot of customers who can handle an application quite easier
if important steps are dialog guided. While data entry is often trival
for a developer it is not for a user.


mfG
--> stefan <--
 
R

Rick Brandt

Hi Guys and Gals

I know this is probably a really simple thing to do, but I want to
change the properties of an Access form from code. The property I want
to change expressly is DataEntry. Because I would like to use the same
form for "data entry only" as I do for viewing and editing records.
Alternatively, if anyone knows a better way to deal with something like
this. Ultimately, I would also like to be able to change the DataSource
property as well depending on how the form is opened.

Cheers

Stephen @ ZennHAUS

You can control all of this in the code that opens the form. Set the
form to have DataEntry = False as the default. Then to open for "viewing
and editing"...

DoCmd.OpenForm "FormName"

When you want to open it in DataEntry mode...

DoCmd.OpenForm "FormName",,,,acFormAdd

The last argument above specifies to open the form in DataEntry mode.
 
S

Stephen @ ZennHAUS

Seems simple enough Rick. Thanks. Now that I see what you wrote, I kinda
realise I have done that before but forgot how. My bad.

Cheers

Stephen @ ZennHAUS
 
S

Stephen @ ZennHAUS

Hey Stefan

I had tried to load the form, set the properties just by using the code
frmSomeForm.DataEntry = true but I was grasping at straws I think and that
probably isn't valid code anyway. In the past I have typically separated
operations by having an Add form, a View form and an Edit form so that every
data operation is a very conscious action. I was just hoping that I might be
able to modify the mode then manage the controls that were visible based on
the forms mode to reduce the number of forms required.

Rick Brandt also replied to my post indicating that i could just use
DoCmd.OpenForm with the acFormAdd option which will set the form to Add mode
anyway.

Thanks for your help

Stephen @ ZennHAUS
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top