Conditional Control Source

G

Guest

I'm trying to expand the usability of this text box ("Tensile Test") by
switching the rcontrol source if the data in it is currently null, or false
(or not checked). Right now, the check box uses this as the control source:
DLookUp("[chkOp120]","Process Codes","[ID Process Key] =" & Forms![Order
Entry]![ID Process Key])
If the Process Code on the current record of the form matches a Process Code
from the Process Codes table that is checked, then a Tensile Test is
required. However, sometimes tensile tests are requested by the customer on
a case by case basis. So I need to be able to check the "Tensile Test" check
box for that particular order only. If seen that DLookup can be used in
conditional controlsource statements like:
=IIf([0830]>=2, DLookup("[LastName] & ', ' & [FirstName]","tblPatients",
"[PatientID] =" & [0830]), Null)

Could I not use a conditional statement to check the table, and change the
control source if it's negative, or false?
 
T

tina

suggest you bind the checkbox control to the field in the underlying table
and leave it bound. then write some code to check the value of [ID Process
Key] on the form's Current event and also the [ID Process Key]'s AfterUpdate
event (if the value may be changed by data entry in the form), and set the
value of the checkbox accordingly. something along the lines of

If Me!TensileTest = False Then
Me!TensileTest = DLookup("[chkOp120]", _
"Process Codes", "[ID Process Key] = " _
& Me![ID Process Key])
End If

replace "TensileTest" with the correct name of the checkbox control, of
course.

hth
 
G

Guest

Yes you can. The Form Current event is probably the place you want to do
that so you will have it set correctly for the current record. The Current
event also fires for new records, so you will want to make the selection for
them as well.
 
G

Guest

Ah. Silly me! And here I was, trying to stuff all that into the
ControlSource Property of the form... Thanks Tina and Dave! You're the
best! BTW, isn't Klatuu one of those "old god" names? Like the ones
Moorcock and Lovecraft write about?
--
Why are you asking me? I dont know what Im doing!

Jaybird


Klatuu said:
Yes you can. The Form Current event is probably the place you want to do
that so you will have it set correctly for the current record. The Current
event also fires for new records, so you will want to make the selection for
them as well.
--
Dave Hargis, Microsoft Access MVP


Jaybird said:
I'm trying to expand the usability of this text box ("Tensile Test") by
switching the rcontrol source if the data in it is currently null, or false
(or not checked). Right now, the check box uses this as the control source:
DLookUp("[chkOp120]","Process Codes","[ID Process Key] =" & Forms![Order
Entry]![ID Process Key])
If the Process Code on the current record of the form matches a Process Code
from the Process Codes table that is checked, then a Tensile Test is
required. However, sometimes tensile tests are requested by the customer on
a case by case basis. So I need to be able to check the "Tensile Test" check
box for that particular order only. If seen that DLookup can be used in
conditional controlsource statements like:
=IIf([0830]>=2, DLookup("[LastName] & ', ' & [FirstName]","tblPatients",
"[PatientID] =" & [0830]), Null)

Could I not use a conditional statement to check the table, and change the
control source if it's negative, or false?
 
G

Guest

Actually, it is a misspelling of Klaatu, the Michael Rainy character from the
movie "The Day the Earth Stood Still".
Younger folks attribute it to "Army of Darkness" where Bruce Campbell (The
world's best bad actor) quotes from "The Day the Earth Stood STill", "Klaatu,
Barada Nikto"
What that actually means is still debated to this day.
--
Dave Hargis, Microsoft Access MVP


Jaybird said:
Ah. Silly me! And here I was, trying to stuff all that into the
ControlSource Property of the form... Thanks Tina and Dave! You're the
best! BTW, isn't Klatuu one of those "old god" names? Like the ones
Moorcock and Lovecraft write about?
--
Why are you asking me? I dont know what Im doing!

Jaybird


Klatuu said:
Yes you can. The Form Current event is probably the place you want to do
that so you will have it set correctly for the current record. The Current
event also fires for new records, so you will want to make the selection for
them as well.
--
Dave Hargis, Microsoft Access MVP


Jaybird said:
I'm trying to expand the usability of this text box ("Tensile Test") by
switching the rcontrol source if the data in it is currently null, or false
(or not checked). Right now, the check box uses this as the control source:
DLookUp("[chkOp120]","Process Codes","[ID Process Key] =" & Forms![Order
Entry]![ID Process Key])
If the Process Code on the current record of the form matches a Process Code
from the Process Codes table that is checked, then a Tensile Test is
required. However, sometimes tensile tests are requested by the customer on
a case by case basis. So I need to be able to check the "Tensile Test" check
box for that particular order only. If seen that DLookup can be used in
conditional controlsource statements like:
=IIf([0830]>=2, DLookup("[LastName] & ', ' & [FirstName]","tblPatients",
"[PatientID] =" & [0830]), Null)

Could I not use a conditional statement to check the table, and change the
control source if it's negative, or false?
 

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