Value of a Fiele based on another field

m17347047711116

Registered User.
Local time
Today, 11:55
Joined
Feb 4, 2002
Messages
68
I have a form with a sub form

I would like to put a control box on my form that will display a certain value depending on the values in one of the fields on my primary form and another field on my Sub Form

Scenario:

[SHIFT] this field is on my Main Form
[CURRENT SHIFT] Variable control i would like to add

[SHIFT ON DAYS] This field is on my Sub Form
[SHIFT ON AFT] This field is on my Sub Form

Would like to put a control box on my main form that will look at the value in the [SHIFT] control box, compare it to the values in the [SHIFT ON DAYS] and [SHIFT ON AFT] and [SHIFT ON NIGHTS]
field in my Sub Form, and depending on which one matches display the following messages in the [CURRENT SHIFT]

" This Employee is on DAY Shift"
" This Employee is On AFT Shift"
" This Employee is On Nights"
 
Best way might be to write code using the Select Case Statement (good example in A2K Help).

But If Else statements are easier to grasp, definitely easier to come back to if you don't write code every day, and, too, nice for illustration:

Assuming I haven't undersold the complexity of your problem, experiment with code similar to the following, placing it in the On Current Event of your Sub Form.

Code:
If Forms!MainForm!Shift.Value = Forms!MainForm!SubForm!ShiftOnDays.Value Then
Forms!MainForm!CurrentShift = "This Employee is on DAY Shift"

ElseIF Forms!MainForm!Shift.Value = Forms!MainForm!SubFormShiftOnAft.Value Then
Forms!MainForm!CurrentShift = "This Employee is on AFT Shift"

Else 
Forms!MainForm!CurrentShift = "This Poor Guy works Night Shift"
Regards,
Tim
 

Users who are viewing this thread

Back
Top Bottom