Group:  Microsoft Access ยป microsoft.public.access.formscoding
Thread: Changing form properties from VBA code

Geek News

Changing form properties from VBA code
"Stephen [ at ] ZennHAUS" <stephen.huisman[ at ]zennhaus.com> 12/14/2008 12:11:12 PM
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 [ at ] ZennHAUS

Re: Changing form properties from VBA code
Stefan Hoffmann <ste5an[ at ]ste5an.de> 12/14/2008 12:29:01 PM
hi Stephen,

Stephen [ at ] ZennHAUS wrote:
[Quoted Text]
> 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 <--
Re: Changing form properties from VBA code
Rick Brandt <rickbrandt2[ at ]hotmail.com> 12/14/2008 1:31:26 PM
On Sun, 14 Dec 2008 23:11:12 +1100, Stephen [ at ] ZennHAUS wrote:

[Quoted Text]
> 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 [ at ] 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.



--
Rick Brandt, Microsoft Access MVP
Email (as appropriate) to...
RBrandt at Hunter dot com
Re: Changing form properties from VBA code
"Stephen [ at ] ZennHAUS" <stephen.huisman[ at ]zennhaus.com> 12/14/2008 8:23:15 PM
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 [ at ] ZennHAUS

"Rick Brandt" <rickbrandt2[ at ]hotmail.com> wrote in message
news:OU71l.10120$x%.6984[ at ]nlpi070.nbdc.sbc.com...
[Quoted Text]
> On Sun, 14 Dec 2008 23:11:12 +1100, Stephen [ at ] ZennHAUS wrote:
>
>> 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 [ at ] 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.
>
>
>
> --
> Rick Brandt, Microsoft Access MVP
> Email (as appropriate) to...
> RBrandt at Hunter dot com

Re: Changing form properties from VBA code
"Stephen [ at ] ZennHAUS" <stephen.huisman[ at ]zennhaus.com> 12/14/2008 8:29:26 PM
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 [ at ] ZennHAUS

"Stefan Hoffmann" <ste5an[ at ]ste5an.de> wrote in message
news:eJvHTeeXJHA.5108[ at ]TK2MSFTNGP04.phx.gbl...
[Quoted Text]
> hi Stephen,
>
> Stephen [ at ] ZennHAUS wrote:
>> 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 <--

Home | Search | Terms | Imprint Contact
Newsgroups Reader - provided by WiredBox.Net