Enablesand odd behavior

  • Thread starter Thread starter Andrew Stephens
  • Start date Start date
A

Andrew Stephens

I have setup a form where the value in a combo box
determines if a check box is enabled.

This code is called when the combo box is changed.

IF combobox.value = "TEMP" then
checkbox.enabled = TRUE
ELSE: ccheckbox.enabled = FALSE

I have also added the same code to the form's onCurrent
section since this should execute when we navigate to a
new record.

The problem I am seeing is that the checkbox is not being
enabled in old records. i.e. when I enter a new record
it works and when I browse to an old record that already
has TEMP in the combobox, the checkbox is not enabled.

I also know it is not an issue with timing and accessing
the mssql database since I tried putting the code in as a
timer event and have it occur every second, the old
records would still not activate.

The kicker is that if I toggle the combobox, on an old
record,to a different value then back to TEMP, it will
now function properly. I know the code that I have
written works since when I put it on the timer event I
could see that the checkbox was enabled a second after
the record was displayed.

What I need to happen is for the checkbox to be enabled
on all the records (even the old ones) where the combobox
value is TEMP. What I was thinking is that the enable
setting for that record is stored somewhere and only gets
updated at certain instances. How do I force this update
or fix my problem?

Thanks,
Andrew
andrew.stephens<at>intermec.com
 
Andrew said:
I have setup a form where the value in a combo box
determines if a check box is enabled.

This code is called when the combo box is changed.

IF combobox.value = "TEMP" then
checkbox.enabled = TRUE
ELSE: ccheckbox.enabled = FALSE

I have also added the same code to the form's onCurrent
section since this should execute when we navigate to a
new record.

The problem I am seeing is that the checkbox is not being
enabled in old records. i.e. when I enter a new record
it works and when I browse to an old record that already
has TEMP in the combobox, the checkbox is not enabled.
[snip]

It sounds like the form's Current event procedure is not
being entered. Check the OnCurrent property and make sure
it contains [Event Procedure]
 
It sounds like the form's Current event procedure is not
being entered. Check the OnCurrent property and make sure
it contains [Event Procedure]

It does contain [Event Procedure]. The other strange
part of this is that when I am in debug mode it behaves
as it should. I put a break at the procedure call line
and everything gets updated properly when I hit play
after the break. This behavior in debug prompted me to
try the timer case since I thought it might have to do
with a connection to the database that finished after my
code did.

Andrew
 
andrews said:
It sounds like the form's Current event procedure is not
being entered. Check the OnCurrent property and make sure
it contains [Event Procedure]
.

It does contain [Event Procedure]. The other strange
part of this is that when I am in debug mode it behaves
as it should. I put a break at the procedure call line
and everything gets updated properly when I hit play
after the break. This behavior in debug prompted me to
try the timer case since I thought it might have to do
with a connection to the database that finished after my
code did.


I've never seen that kind of thing. If it works with the
delay of the break point, then it does sound like a timing
issue (though I can't think of what the blockage could be).
Try putting a DoEvents as the first line in the Current
event procedure??
 
Had already tried the VBA.DoEvents, but retested it
anyway and still nothing. Here is an interesting fact as
well...when I pull up the data table for the form and I
have a record selected that has that check box enabled
the whole column of check boxes becomes enabled. But
only if it is a new record or one of the cases where I
have toggled the combo box, otherwise the whole thing is
disabled.

Could it be that when I populate the form from the
database, for some reason combobox.value is not set and
only becomes set when you make it "dirty" by toggling
it? If this is so, how do I force it to become define
and/or refrence the value that is displayed?

Andrew
 
Had already tried the VBA.DoEvents, but retested it
anyway and still nothing. Here is an interesting fact as
well...when I pull up the data table for the form and I
have a record selected that has that check box enabled
the whole column of check boxes becomes enabled. But
only if it is a new record or one of the cases where I
have toggled the combo box, otherwise the whole thing is
disabled.

Hold up a minute here. What do you mean by "pull up the
data table for the form". Tables in datasheet view don't
have enabled check box. If you mean the form is in
continuoud view, then that behavior is consistent with what
you've seen all along.

Could it be that when I populate the form from the
database, for some reason combobox.value is not set and
only becomes set when you make it "dirty" by toggling
it? If this is so, how do I force it to become define
and/or refrence the value that is displayed?

Are you sure the check box in the form is bound to a record
source field?

I'm just grasping at straws there, I really have no idea how
this could happen.
 
I bring the form up, right click on it and select
datasheet view. The last column (which is my new
checkbox) has a checkbox representation. This checkbox
is tied to a data column in my mssql databse and that
column is an int. That column is populated with all
zeros (i.e. not <NULL>) I am starting to think it has
something to do whith when the combobox.value variable is
actually defined. This whole process is getting to the
point where it will just get left "as is" and if they
really want to use that check box when the combobox has
TEMP in it, they will just hav eto toggle it for that
record. Thanks for the suggestion, email me if you think
of anything else. (email in first post)

Andrew

-----Original Message-----
Had already tried the VBA.DoEvents, but retested it
anyway and still nothing. Here is an interesting fact as
well...when I pull up the data table for the form and I
have a record selected that has that check box enabled
the whole column of check boxes becomes enabled. But
only if it is a new record or one of the cases where I
have toggled the combo box, otherwise the whole thing is
disabled.

Hold up a minute here. What do you mean by "pull up the
data table for the form". Tables in datasheet view don't
have enabled check box. If you mean the form is in
continuoud view, then that behavior is consistent with what
you've seen all along.

Could it be that when I populate the form from the
database, for some reason combobox.value is not set and
only becomes set when you make it "dirty" by toggling
it? If this is so, how do I force it to become define
and/or refrence the value that is displayed?

Are you sure the check box in the form is bound to a record
source field?

I'm just grasping at straws there, I really have no idea how
this could happen.
--
Marsh
MVP [MS Access]



.
 
I bring the form up, right click on it and select
datasheet view. The last column (which is my new
checkbox) has a checkbox representation. This checkbox
is tied to a data column in my mssql databse and that
column is an int. That column is populated with all
zeros (i.e. not <NULL>) I am starting to think it has
something to do whith when the combobox.value variable is
actually defined. This whole process is getting to the
point where it will just get left "as is" and if they
really want to use that check box when the combobox has
TEMP in it, they will just hav eto toggle it for that
record. Thanks for the suggestion, email me if you think
of anything else. (email in first post)


I really don't have anything to add, just never seen this
kind of thing before.

Note that switching the form to sheet view is not going to
change its behavior. The fact that the entire column looks
disabled when you disable the check box is normal (there is
only one set of control properties that are used for all of
the rows).
--
Marsh
MVP [MS Access]

-----Original Message-----
Had already tried the VBA.DoEvents, but retested it
anyway and still nothing. Here is an interesting fact as
well...when I pull up the data table for the form and I
have a record selected that has that check box enabled
the whole column of check boxes becomes enabled. But
only if it is a new record or one of the cases where I
have toggled the combo box, otherwise the whole thing is
disabled.

Hold up a minute here. What do you mean by "pull up the
data table for the form". Tables in datasheet view don't
have enabled check box. If you mean the form is in
continuoud view, then that behavior is consistent with what
you've seen all along.

Could it be that when I populate the form from the
database, for some reason combobox.value is not set and
only becomes set when you make it "dirty" by toggling
it? If this is so, how do I force it to become define
and/or refrence the value that is displayed?

Are you sure the check box in the form is bound to a record
source field?

I'm just grasping at straws there, I really have no idea how
this could happen.
--
Marsh
MVP [MS Access]


Marshall Barton wrote:
I've never seen that kind of thing. If it works with the
delay of the break point, then it does sound like a
timing
issue (though I can't think of what the blockage could
be).
Try putting a DoEvents as the first line in the Current
event procedure??

.
 
Back
Top