[SOLVED] Driving input from one form to update another
Good morning. I am having an issue with this code that I cannot figure out.
I am attempting to update one form based on inputs to another.
1. AircraftDatasheetForm (Form not open, being updated)
2. Flight (Form open and being changed, driving the update to AircraftDatasheetForm)
I have three fields in the Flight form that are driving the update.
1. Airborne (denotes aircraft is airborne)
2. Fifteen (denotes the aircraft is 15 min out from landing)
3. OnDeck (denotes the time the aircraft has landed)
I have one field in the AircraftDatasheetForm I want to update based on Airborne, Fifteen and OnDeck fields from the Flight Form.
1. FlightStatus
Both forms have one thing in common, the ‘side’ number of the aircraft that is being flown.
When the Airborne, Fifteen or OnDeck field is checked yes I want the following to occur:
1. Airborne (puts a number 1 in the FlightStatus field on the AircraftDatasheetForm)
2. Fifteen (puts a number 2 in the FlightStatus field on the AircraftDatasheetForm)
3. Fifteen (puts a number 3 in the FlightStatus field on the AircraftDatasheetForm)
If the Airborne was checked ‘Yes’ and subsequently checked ‘No’ I wanted to revert the FlightStatus back to 3 (meaning OnDeck)
Note, during the course of the day the same aircraft will fly multiple times, thus will have several records in the Flight form, however it only has one line in the AircraftDatasheetForm (defining itself). The update in FlightStatus will be driven off the latest Airborne/Fifteen/OnDeck entry.
The below code seems to work, however if I test it with multiple changes it eventually does not complete the update. I also noticed a conditional format I have in a field labeled ‘Side’ in the AircraftDatasheetForm based on the FlightStatus field does not automatically update after this AfterUpdate code is completed. Is there some type of code I need to put into this to drive something in the AircraftDatasheetForm to trigger the update of that form, subsequently the conditional format as well and so that if someone has the AircraftDatasheetForm open they will immediately see the change in FlightStatus?
Also note, I tied a few ‘And’s in the code in the event someone unchecks some type of combination of the Airborne/Fifteen/OnDeck it will give me the most logical result.
Most thanks in advance for your help.
Good morning. I am having an issue with this code that I cannot figure out.
I am attempting to update one form based on inputs to another.
1. AircraftDatasheetForm (Form not open, being updated)
2. Flight (Form open and being changed, driving the update to AircraftDatasheetForm)
I have three fields in the Flight form that are driving the update.
1. Airborne (denotes aircraft is airborne)
2. Fifteen (denotes the aircraft is 15 min out from landing)
3. OnDeck (denotes the time the aircraft has landed)
I have one field in the AircraftDatasheetForm I want to update based on Airborne, Fifteen and OnDeck fields from the Flight Form.
1. FlightStatus
Both forms have one thing in common, the ‘side’ number of the aircraft that is being flown.
When the Airborne, Fifteen or OnDeck field is checked yes I want the following to occur:
1. Airborne (puts a number 1 in the FlightStatus field on the AircraftDatasheetForm)
2. Fifteen (puts a number 2 in the FlightStatus field on the AircraftDatasheetForm)
3. Fifteen (puts a number 3 in the FlightStatus field on the AircraftDatasheetForm)
If the Airborne was checked ‘Yes’ and subsequently checked ‘No’ I wanted to revert the FlightStatus back to 3 (meaning OnDeck)
Note, during the course of the day the same aircraft will fly multiple times, thus will have several records in the Flight form, however it only has one line in the AircraftDatasheetForm (defining itself). The update in FlightStatus will be driven off the latest Airborne/Fifteen/OnDeck entry.
The below code seems to work, however if I test it with multiple changes it eventually does not complete the update. I also noticed a conditional format I have in a field labeled ‘Side’ in the AircraftDatasheetForm based on the FlightStatus field does not automatically update after this AfterUpdate code is completed. Is there some type of code I need to put into this to drive something in the AircraftDatasheetForm to trigger the update of that form, subsequently the conditional format as well and so that if someone has the AircraftDatasheetForm open they will immediately see the change in FlightStatus?
Also note, I tied a few ‘And’s in the code in the event someone unchecks some type of combination of the Airborne/Fifteen/OnDeck it will give me the most logical result.
Most thanks in advance for your help.
Code:
[SIZE=3][FONT=Calibri] If Airborne And Fifteen And Side = Forms![AircraftDatasheetForm]![Side] Then[/FONT][/SIZE]
[SIZE=3][FONT=Calibri] Forms![AircraftDatasheetForm]![FlightStatus] = 2[/FONT][/SIZE]
[SIZE=3][FONT=Calibri] Else[/FONT][/SIZE]
[SIZE=3][FONT=Calibri] If Airborne And OnDeck And Side = Forms![AircraftDatasheetForm]![Side] Then[/FONT][/SIZE]
[SIZE=3][FONT=Calibri] Forms![AircraftDatasheetForm]![FlightStatus] = 3[/FONT][/SIZE]
[SIZE=3][FONT=Calibri] Else[/FONT][/SIZE]
[SIZE=3][FONT=Calibri] Forms![AircraftDatasheetForm]![FlightStatus] = 1[/FONT][/SIZE]
[SIZE=3][FONT=Calibri] End If[/FONT][/SIZE]
Last edited: