Calculated Field & Buttons

G

Guest

Hi All,

I have a calculated field that i want to use to enable or diable a button on
a subform.

The calculated field counts whether the right number of mandatory field have
been filled in and then if the right number have been filled in then the
button is enabled to show another field.

I know i could put check on each field that is manually filled in to do this
but as there can be between 20 and 30 mandatory fields, its a pain and seems
like overkill.

I really want it to work when the calculated field changes, is there anyway
of doing this, i know the AfterUpdate and OnChange field don't work.

Thanks for your help.
 
J

Jeff Boyce

Emma

How does your calculated field get updated? Don't you already have to have
a routine in each field that reminds Access to update that calculated field?
If so, you could add in the check to see if the command button can be
enabled.

Regards

Jeff Boyce
Microsoft Office/Access MVP
 
G

Guest

My calculated field is along the lines of iif([Field 1] is
null,0,1)+iif([Field2] is null,0,1) etc

and the disabling code is along the lines of select case [Calculated
Field].value case 25: [Button].enabled = true Case else: [Button].enabled =
false End Select

There is nothing more complicated than that, what i need to know is what
event to put my code on,i know i can put it on the AfterUpdate of Field1,
Field2........Field25 but it seems long winded, i just want it to trigger
from the [Calculated Field] if possible.
 
J

Jeff Boyce

Emma

How will the calculated field "know" that something changed in one of the
other fields?

Another approach might be to add a subroutine to the form (not to any
field/event). That subroutine will do the calculation and set the
cmdButton.Enabled property.

Then you'd need to add a small bit of code to each Field's AfterUpdate
event, something like:

Call CheckMyFields()

(where that was the name of the general routine you wrote "behind" the
form.)

Regards

Jeff Boyce
Microsoft Office/Access MVP

Emma Hope said:
My calculated field is along the lines of iif([Field 1] is
null,0,1)+iif([Field2] is null,0,1) etc

and the disabling code is along the lines of select case [Calculated
Field].value case 25: [Button].enabled = true Case else: [Button].enabled
=
false End Select

There is nothing more complicated than that, what i need to know is what
event to put my code on,i know i can put it on the AfterUpdate of Field1,
Field2........Field25 but it seems long winded, i just want it to trigger
from the [Calculated Field] if possible.



Jeff Boyce said:
Emma

How does your calculated field get updated? Don't you already have to
have
a routine in each field that reminds Access to update that calculated
field?
If so, you could add in the check to see if the command button can be
enabled.

Regards

Jeff Boyce
Microsoft Office/Access MVP
 
G

Guest

I don't know how the calculated field "knows" that something has changed in
one of the other fields, it just does. If i fill something in Field1, then my
calculated field goes up by 1 (on the basis that the control source is
iif([Field1] is null, 0,1)+iif([Field2] is null,0,1) etc.

I really don't want to put a AfterUpdate on all my fields if possible as i
mentioned in the two previous posts as it seems like overkill and long winded
but it looks like there is no other way.



Jeff Boyce said:
Emma

How will the calculated field "know" that something changed in one of the
other fields?

Another approach might be to add a subroutine to the form (not to any
field/event). That subroutine will do the calculation and set the
cmdButton.Enabled property.

Then you'd need to add a small bit of code to each Field's AfterUpdate
event, something like:

Call CheckMyFields()

(where that was the name of the general routine you wrote "behind" the
form.)

Regards

Jeff Boyce
Microsoft Office/Access MVP

Emma Hope said:
My calculated field is along the lines of iif([Field 1] is
null,0,1)+iif([Field2] is null,0,1) etc

and the disabling code is along the lines of select case [Calculated
Field].value case 25: [Button].enabled = true Case else: [Button].enabled
=
false End Select

There is nothing more complicated than that, what i need to know is what
event to put my code on,i know i can put it on the AfterUpdate of Field1,
Field2........Field25 but it seems long winded, i just want it to trigger
from the [Calculated Field] if possible.



Jeff Boyce said:
Emma

How does your calculated field get updated? Don't you already have to
have
a routine in each field that reminds Access to update that calculated
field?
If so, you could add in the check to see if the command button can be
enabled.

Regards

Jeff Boyce
Microsoft Office/Access MVP


Hi All,

I have a calculated field that i want to use to enable or diable a
button
on
a subform.

The calculated field counts whether the right number of mandatory field
have
been filled in and then if the right number have been filled in then
the
button is enabled to show another field.

I know i could put check on each field that is manually filled in to do
this
but as there can be between 20 and 30 mandatory fields, its a pain and
seems
like overkill.

I really want it to work when the calculated field changes, is there
anyway
of doing this, i know the AfterUpdate and OnChange field don't work.

Thanks for your help.
 
J

Jeff Boyce

Perhaps one of the other newsgroup readers has a one-place-only solution.

I can understand that the calculated control takes its value from the sum of
the "fields". But you're asking for a way to tell when the value of the
calculated control reaches some limit. That's an event. I believe you'll
need an event somewhere to "fire" to confirm whether the count has reached
the limit.

I've not done any testing, but perhaps there's an event at the Form level
that fires after each change to any object on the form.

Regards

Jeff Boyce
Microsoft Office/Access MVP


Emma Hope said:
I don't know how the calculated field "knows" that something has changed in
one of the other fields, it just does. If i fill something in Field1, then
my
calculated field goes up by 1 (on the basis that the control source is
iif([Field1] is null, 0,1)+iif([Field2] is null,0,1) etc.

I really don't want to put a AfterUpdate on all my fields if possible as i
mentioned in the two previous posts as it seems like overkill and long
winded
but it looks like there is no other way.



Jeff Boyce said:
Emma

How will the calculated field "know" that something changed in one of the
other fields?

Another approach might be to add a subroutine to the form (not to any
field/event). That subroutine will do the calculation and set the
cmdButton.Enabled property.

Then you'd need to add a small bit of code to each Field's AfterUpdate
event, something like:

Call CheckMyFields()

(where that was the name of the general routine you wrote "behind" the
form.)

Regards

Jeff Boyce
Microsoft Office/Access MVP

Emma Hope said:
My calculated field is along the lines of iif([Field 1] is
null,0,1)+iif([Field2] is null,0,1) etc

and the disabling code is along the lines of select case [Calculated
Field].value case 25: [Button].enabled = true Case else:
[Button].enabled
=
false End Select

There is nothing more complicated than that, what i need to know is
what
event to put my code on,i know i can put it on the AfterUpdate of
Field1,
Field2........Field25 but it seems long winded, i just want it to
trigger
from the [Calculated Field] if possible.



:

Emma

How does your calculated field get updated? Don't you already have to
have
a routine in each field that reminds Access to update that calculated
field?
If so, you could add in the check to see if the command button can be
enabled.

Regards

Jeff Boyce
Microsoft Office/Access MVP


Hi All,

I have a calculated field that i want to use to enable or diable a
button
on
a subform.

The calculated field counts whether the right number of mandatory
field
have
been filled in and then if the right number have been filled in then
the
button is enabled to show another field.

I know i could put check on each field that is manually filled in to
do
this
but as there can be between 20 and 30 mandatory fields, its a pain
and
seems
like overkill.

I really want it to work when the calculated field changes, is there
anyway
of doing this, i know the AfterUpdate and OnChange field don't work.

Thanks for your help.
 

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