Single Entry vs. All Entry Coding

M

Michelle F

This is a general question by a relative newbie to VBA. I have a form that
contains (among other things) optional areas for entering vote and comment
information. I have created a checkbox for each that, when selected, enables
the boxes for entering the information I have successfully coded the form to
open with the requisite areas disabled and have coded it such that, when the
checkbox is selected, the areas enable and vice versa.

The problem is that the form applies the settings (enabled/disabled) to ALL
the records, not just the one that is open. So, for Record A I want to
enable the vote feature, so I click the box, enter my info, and move on to
Record B. But then Record B the feature is ENABLED when it should be
DISABLED because I have not checked the box! If I check the vote box and
then uncheck it again for Record B, the field is disabled, but then it is
also disabled for Record A!

I originally created the checkboxs (and stored values) to combat this,
thinking that if I referenced a stored value for the specific record
(checked/unchecked) it would only apply the enabled/disabled for that record.
No such luck!

As a newbie, I would appreciate descriptive answers as I don't quite
understand issues like "SetFocus" but think that it may have something to do
with this.

Thanks a mil!

Michelle
 
J

John W. Vinson

This is a general question by a relative newbie to VBA. I have a form that
contains (among other things) optional areas for entering vote and comment
information. I have created a checkbox for each that, when selected, enables
the boxes for entering the information I have successfully coded the form to
open with the requisite areas disabled and have coded it such that, when the
checkbox is selected, the areas enable and vice versa.

The problem is that the form applies the settings (enabled/disabled) to ALL
the records, not just the one that is open. So, for Record A I want to
enable the vote feature, so I click the box, enter my info, and move on to
Record B. But then Record B the feature is ENABLED when it should be
DISABLED because I have not checked the box! If I check the vote box and
then uncheck it again for Record B, the field is disabled, but then it is
also disabled for Record A!

You'll need to enable and disable the controls in *two places*: the
AfterUpdate event of the checkbox (which you're apparently doing already), and
also in the Form's Current event. The Current event fires when you move to a
different record; when you get to that record, you need to set the properties
of the controls to whatever is appropriate for that record.
 
J

Jeff Boyce

Michelle

It sounds like your form may be set to "continuous". I've heard of that
kind of behavior (where all records are affected by one record's setting).

Another approach is to use a single form, designed to appear like a single
row. Then you can open the window tall enough for several (single) records
to display. In this design, checking one record's checkbox doesn't affect
any other record's checkbox.

Regards

Jeff Boyce
Microsoft Office/Access MVP
 
M

Michelle F

Thanks! That fixed it. It took some finagling with the code, but I got it
to work perfect. Along a similar note, I have all the fields set to "locked"
by default because it is often used to just view data. I locked everything
so people couldn't inadvertently change info. However, the "locked" button
is not tied to the underlying data at all. Is there a way to have it default
to "locked" for each record viewed, even if the previous was enabled to make
data changes? I have the "OnClick" events for the button, but am not sure
how to make it work besides the "OnLoad" event used for opening the form.
 
J

John W. Vinson

Thanks! That fixed it. It took some finagling with the code, but I got it
to work perfect. Along a similar note, I have all the fields set to "locked"
by default because it is often used to just view data. I locked everything
so people couldn't inadvertently change info. However, the "locked" button
is not tied to the underlying data at all. Is there a way to have it default
to "locked" for each record viewed, even if the previous was enabled to make
data changes? I have the "OnClick" events for the button, but am not sure
how to make it work besides the "OnLoad" event used for opening the form.

You'll also need to Lock the controls in the Current event.

Just bear in mind... the properties of a Form and of controls on a Form are
properties *of the form as an object*. They are not properties of a Table or
of a record in the table. If I clean my office window it won't clear up the
pollution haze over the Treasure Valley, and vice versa!
 

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