enabled true/false

J

johnlute

This isn't working:
Me.IDAreasqinmin.Enabled = IsNull(Me.IDAreasqinr = True)
Me.IDAreasqinmin.Enabled = False = IsNull(Me.IDAreasqinr = False)

I suspect it's because Me.IDAreasqinr is a calculated value...? How
can I change the above to account for a calculated value?

Thanks!
 
T

theDBguy

Hi,

Maybe try something like:

Me.IDAreasqinmin.Enabled = Me.IDAreasqinr > ""

Hope that helps...
 
J

johnlute

Thanks! That works great. I have the code in the AfterUpdate Event and
the form's OnCurrent Event. It doesn't enable/disable the
[IDAreasqinr] control unless I leave the current record and then
navigate back to it.

Is this because [IDAreasqinr] is a calculated value?
 
T

theDBguy

On second thought, maybe you should try something like:

Me.IDAreasqinmin.Enabled = Not Me.IDAreasqinr > ""

Hope that helps...
 
M

Marshall Barton

johnlute said:
This isn't working:
Me.IDAreasqinmin.Enabled = IsNull(Me.IDAreasqinr = True)
Me.IDAreasqinmin.Enabled = False = IsNull(Me.IDAreasqinr = False)

I suspect it's because Me.IDAreasqinr is a calculated value...? How
can I change the above to account for a calculated value?


How is the value calculated?

If it's calculated in a control source expression, then
checking its value in VBA code will frequently fail to work.
In this case, finding a way to move the calculation from a
control source expression to an appropriate VBA procedure
should resolve the problem.

If it's calculated in a VBA procedure, then make sure it's
in an appropriate event.

If it's calculated in the record source query, then I have
no idea why it would not work.
 
J

johnlute

Hi, Marsh.
How is the value calculated?

If it's calculated in the record source query, then I have
no idea why it would not work.

This is precisely where it's calculated which is why I can't
understand why it's not working, either. You're skills are much more
advanced than mine and if you have no idea then I'm in big trouble!

I tinkered with DBguy's suggestions which provided the same results
which is that [IDAreasqinr] won't enable/disable unless I leave the
current record and then navigate back to it. Do I need to add a If
Me.Dirty Then Me.Dirty = False?

I went back to this:
Private Sub IDAreasqinr_AfterUpdate()
Me.IDAreasqinmin.Enabled = IsNull(Me.IDAreasqinr = True)
Me.IDAreasqinmin.Enabled = False = IsNull(Me.IDAreasqinr = False)

End Sub
 
T

theDBguy

Hi,

Can you post the Control Source for the calculated value?

Thanks.


johnlute said:
Hi, Marsh.
How is the value calculated?

If it's calculated in the record source query, then I have
no idea why it would not work.

This is precisely where it's calculated which is why I can't
understand why it's not working, either. You're skills are much more
advanced than mine and if you have no idea then I'm in big trouble!

I tinkered with DBguy's suggestions which provided the same results
which is that [IDAreasqinr] won't enable/disable unless I leave the
current record and then navigate back to it. Do I need to add a If
Me.Dirty Then Me.Dirty = False?

I went back to this:
Private Sub IDAreasqinr_AfterUpdate()
Me.IDAreasqinmin.Enabled = IsNull(Me.IDAreasqinr = True)
Me.IDAreasqinmin.Enabled = False = IsNull(Me.IDAreasqinr = False)

End Sub
.
 
J

johnlute

Hi, DBguy.

The following may seem a bit odd and there's probably an easier way to
do it but keep in mind that my skills aren't very high. The underlying
query calculates the [IDAreasqin] and then [IDAreasqinr] simply rounds
the value in [IDAreasqin] to 4 decimal places.

To be honest I can't recall exactly why I set it up like this but it
produces the desired results:

IDAreasqin: IIf(IsNull([IDAreasq]),[IDAreasq],IIf(DLookUp
("sqinConvFactor","tblUOMLength","txtUOMLength='" & [IDAreaUOM] & "'")
Is Null,Null,Round(DLookUp
("sqinConvFactor","tblUOMLength","txtUOMLength='" & [IDAreaUOM] & "'")*
[IDAreasq],4)))

IDAreasqinr: Round([IDAreasqin],4)

Hi,

Can you post the Control Source for the calculated value?

Thanks.



johnlute said:
Hi, Marsh.
This is precisely where it's calculated which is why I can't
understand why it's not working, either. You're skills are much more
advanced than mine and if you have no idea then I'm in big trouble!
I tinkered with DBguy's suggestions which provided the same results
which is that [IDAreasqinr] won't enable/disable unless I leave the
current record and then navigate back to it. Do I need to add a If
Me.Dirty Then Me.Dirty = False?
I went back to this:
Private Sub IDAreasqinr_AfterUpdate()
Me.IDAreasqinmin.Enabled = IsNull(Me.IDAreasqinr = True)
Me.IDAreasqinmin.Enabled = False = IsNull(Me.IDAreasqinr = False)
End Sub
.- Hide quoted text -

- Show quoted text -
 
M

Mike Painter

johnlute said:
This isn't working:
Me.IDAreasqinmin.Enabled = IsNull(Me.IDAreasqinr = True)
Me.IDAreasqinmin.Enabled = False = IsNull(Me.IDAreasqinr = False)

In both cases (Me.IDAreasqinr = True) and (Me.IDAreasqinr = False) the value
returned will NEVER be null unless Me.IDAreasqinr is null.

Me.IDAreasqinmin.Enabled = IsNull(Me.IDAreasqinr) enables if it is null and
disables if False
I'm Guessing
Me.IDAreasqinmin.Enabled = Not IsNull(Me.IDAreasqinr)

I ususally do this with an IF statement for clarity.
 
T

theDBguy

Hi,

Thanks for posting your calculation. Since you are using DLookup(), your
calculation relies on records that are committed to the table. If you are
making changes on the form and expects the code to work right away, you may
have to force a record save in the AfterUpdate event, as you have mentioned
earlier.

Another option might be to change your calculation to remove the DLookup()
and use a form reference in its place. That is, if the value you are looking
for is in your form, you can use the Forms!FormName.ControlName syntax in
place of the DLookup().

Just my 2 cents...

johnlute said:
Hi, DBguy.

The following may seem a bit odd and there's probably an easier way to
do it but keep in mind that my skills aren't very high. The underlying
query calculates the [IDAreasqin] and then [IDAreasqinr] simply rounds
the value in [IDAreasqin] to 4 decimal places.

To be honest I can't recall exactly why I set it up like this but it
produces the desired results:

IDAreasqin: IIf(IsNull([IDAreasq]),[IDAreasq],IIf(DLookUp
("sqinConvFactor","tblUOMLength","txtUOMLength='" & [IDAreaUOM] & "'")
Is Null,Null,Round(DLookUp
("sqinConvFactor","tblUOMLength","txtUOMLength='" & [IDAreaUOM] & "'")*
[IDAreasq],4)))

IDAreasqinr: Round([IDAreasqin],4)

Hi,

Can you post the Control Source for the calculated value?

Thanks.



johnlute said:
Hi, Marsh.
How is the value calculated?
If it's calculated in the record source query, then I have
no idea why it would not work.
This is precisely where it's calculated which is why I can't
understand why it's not working, either. You're skills are much more
advanced than mine and if you have no idea then I'm in big trouble!
I tinkered with DBguy's suggestions which provided the same results
which is that [IDAreasqinr] won't enable/disable unless I leave the
current record and then navigate back to it. Do I need to add a If
Me.Dirty Then Me.Dirty = False?
I went back to this:
Private Sub IDAreasqinr_AfterUpdate()
Me.IDAreasqinmin.Enabled = IsNull(Me.IDAreasqinr = True)
Me.IDAreasqinmin.Enabled = False = IsNull(Me.IDAreasqinr = False)
End Sub
.- Hide quoted text -

- Show quoted text -

.
 
J

johnlute

Thanks! I'm going to keep tinkering with it given the advice here.

Hi,

Thanks for posting your calculation. Since you are using DLookup(), your
calculation relies on records that are committed to the table. If you are
making changes on the form and expects the code to work right away, you may
have to force a record save in the AfterUpdate event, as you have mentioned
earlier.

Another option might be to change your calculation to remove the DLookup()
and use a form reference in its place. That is, if the value you are looking
for is in your form, you can use the Forms!FormName.ControlName syntax in
place of the DLookup().

Just my 2 cents...



johnlute said:
Hi, DBguy.
The following may seem a bit odd and there's probably an easier way to
do it but keep in mind that my skills aren't very high. The underlying
query calculates the [IDAreasqin] and then [IDAreasqinr] simply rounds
the value in [IDAreasqin] to 4 decimal places.
To be honest I can't recall exactly why I set it up like this but it
produces the desired results:
IDAreasqin: IIf(IsNull([IDAreasq]),[IDAreasq],IIf(DLookUp
("sqinConvFactor","tblUOMLength","txtUOMLength='" & [IDAreaUOM] & "'")
Is Null,Null,Round(DLookUp
("sqinConvFactor","tblUOMLength","txtUOMLength='" & [IDAreaUOM] & "'")*
[IDAreasq],4)))
IDAreasqinr: Round([IDAreasqin],4)
Hi,
Can you post the Control Source for the calculated value?
Thanks.
:
Hi, Marsh.
How is the value calculated?
If it's calculated in the record source query, then I have
no idea why it would not work.
This is precisely where it's calculated which is why I can't
understand why it's not working, either. You're skills are much more
advanced than mine and if you have no idea then I'm in big trouble!
I tinkered with DBguy's suggestions which provided the same results
which is that [IDAreasqinr] won't enable/disable unless I leave the
current record and then navigate back to it. Do I need to add a If
Me.Dirty Then Me.Dirty = False?
I went back to this:
Private Sub IDAreasqinr_AfterUpdate()
Me.IDAreasqinmin.Enabled = IsNull(Me.IDAreasqinr = True)
Me.IDAreasqinmin.Enabled = False = IsNull(Me.IDAreasqinr = False)
End Sub
.- Hide quoted text -
- Show quoted text -
.- Hide quoted text -

- Show quoted text -
 

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