Flight Request Form Help

twac1382

New member
Local time
Today, 09:35
Joined
Mar 20, 2015
Messages
9
I apologize up front, this will be a long post...

I am working on creating a form for our office which tracks flights that are requesting to land on our parking apron. I am to a point where I want to compile all of the input data into shorthand for a Mission Remarks box so that I can simply use that box when I run reports.

BACKGROUND INFO:
Every flight that is requested can have one or multiple of the following options:
-Customs Only (check box)
-Fuel Requested (check box)
-Offload Cargo (check box)
--Rolling Stock (number field)
--Pallets (number field)
--Pallet Trains (text field)
-Onload Cargo (check box)
--Rolling Stock (number field)
--Pallets (number field)
--Pallet Trains (text field)
-Throughload Cargo (check box)
-Explosives (check box)
-Offload Passengers (check box followed by a number field--two separate fields in my table)
-Onload Passengers (check box followed by a number field--two separate fields in my table)
-Throughload Passengers (check box)
-VIP Onload (check box followed by a number field--two separate fields in my table)
-VIP Offload (check box followed by a number field--two separate fields in my table)
-VIP Throughload (check box)

What I would like is when a user clicks the "Update Mission Remarks" button I've created, for all of the above information to get put into a memo field. With the following conditions:

If say the Offload Cargo box is checked (TRUE) then look to the Rolling Stock Pallet fields to see if they have numbers there as well as the Pallet trains...if they do, then I would like to reference them in shorthand on my Mission Remarks box...that's the easy part (which I've done in past attempts), here's where I'm having trouble...if the Offload Cargo box is checked (TRUE) and all three of the fields are empty, I would like it to say "UNKNOWN CARGO"

I've used the following VBA code to mixed results:
Code:
Private Sub UpdateMissionRemarks_Click()
    Dim rmk As String: rmk = ""
    Dim Fuel As String: Fuel = ""
    Dim custonly As String: custonly = ""
    Dim cgooff As String: cgooff = ""
    Dim cgoon As String: cgoon = ""
    Dim cgothru As String: cgothru = ""
    Dim cgoexp As String: cgoexp = ""
    Dim paxoff As String: paxoff = ""
    Dim paxon As String: paxon = ""
    Dim paxthru As String: paxthru = ""
    Dim dvon As String: dvon = ""
    Dim dvoff As String: dvoff = ""
    Dim dvthru As String: dvthru = ""

    If Me.Fuel = True Then
            Fuel = "FUEL"
        Else
    End If
    If Me.CustomsOnly = True Then
            custonly = "CUSTOMS ONLY"
        Else
    End If
    If Me.CargoOffloadBDSC = True Then
                If (IsNull(Me.RollingOff) = True) Then
                    cgooff = Me.PalletOff & " $" & " " & Me.PalletTrainOff
                    If (IsNull(Me.PalletOff) = True) Then
                        cgooff = Me.RollingOff & " RSS" & " " & Me.PalletTrainOff
                        If (IsNull(Me.PalletTrainOff) = True) Then
                            cgooff = Me.RollingOff & " RSS" & " " & Me.PalletOff & " $"
                            If (IsNull(Me.RollingOff) = True) + (IsNull(Me.PalletOff) = True) Then
                                cgooff = Me.PalletTrainOff
                                If (IsNull(Me.RollingOff & Me.PalletOff & Me.PalletTrainOff) = True) Then
                                    cgooff = "UNKNOWN CARGO"
                Else
                End If
                    Else
                    End If
                        Else
                        End If
                            Else
                            End If
                                Else
                                    cgooff = (Me.RollingOff & " RSS") & " " & (Me.PalletOff & " $") & " " & Me.PalletTrainOff
                                End If
        Else
    End If
    If Me.CargoOnloadBDSC = True Then
            cgoon = Nz(Me.RollingOn) & " RSS" & Nz(Me.PalletOn) & " $" & Nz(Me.PalletTrainOn)
        Else
    End If
    If Me.CargoThru = True Then
            cgothru = "CARGO THRU"
        Else
    End If
    If Me.Explosives = True Then
            cgoexp = Me.HighestClass & Me.ExplosivesOnOff & "  (" & Me.NEW & ")"
        Else
    End If
    If Me.PassengersOnloadBDSC = True Then
            paxon = Nz(Me.PassengersOnQuantity) & " Pax"
        Else
    End If
    If Me.PassengersOffloadBDSC = True Then
            paxoff = Nz(Me.PassengersOffQuantity) & " Pax"
        Else
    End If
    If Me.PassengersThruload = True Then
            paxthru = "PAX THRU"
        Else
    End If
    If Me.VIP_DV = True Then
            If Me.VIP_DVOff = True Then
                    dvoff = Me.DVTotalNumber & " DV"
                Else
            End If
            If Me.VIP_DVOn = True Then
                    dvon = Me.DVQtyOn & " DV"
                Else
            End If
            If Me.VIP_DVThru = True Then
                    dvthru = "DV THRU"
                Else
            End If
        Else
    End If

        rmk = custonly & cgooff & " " & cgothru & " " & cgoexp & " " & paxoff & " " & paxthru & " " & dvoff & " " & dvthru & " OFF" & "   " & Fuel & _
        vbCrLf & cgoon & " " & paxon & " " & dvon & " ON"



    Me.CargoRemarks = (rmk)

I appreciate any iput you could give me. I'd be willing to upload a sanitized copy of the form that i'm creating if that would help.

Thanks in advance!
 
well first off your indenting is wrong, which may lead to you interperting the code wrongly... also made a small change to make it "work" better

Code:
    If Me.CargoOffloadBDSC = True Then
                If (IsNull(Me.RollingOff) = True) Then
                    cgooff = Me.PalletOff & " $" & " " & Me.PalletTrainOff
                    If (IsNull(Me.PalletOff) = True) Then
                        cgooff = Me.RollingOff & " RSS" & " " & Me.PalletTrainOff
                        If (IsNull(Me.PalletTrainOff) = True) Then
                            cgooff = Me.RollingOff & " RSS" & " " & Me.PalletOff & " $"
                            If (IsNull(Me.RollingOff) = True) [b]and[/b] (IsNull(Me.PalletOff) = True) Then
                                cgooff = Me.PalletTrainOff
                                If [b]IsNull(Me.RollingOff) and isnull(Me.PalletOff) and isnull(Me.PalletTrainOff)[/b] Then
                                    cgooff = "UNKNOWN CARGO"
                                Else
                                End If
                            Else
                            End If
                        Else
                        End If
                    Else
                    End If
                Else
                    cgooff = (Me.RollingOff & " RSS") & " " & (Me.PalletOff & " $") & " " & Me.PalletTrainOff
                End If
    Else
    End If

Also your code could be a little cleaner...
i.e.
(IsNull(Me.RollingOff) = True)
wouldnt be needed, it needs to be a true/false which isnull already returns, thus
IsNull(Me.RollingOff)
Should be enough, makes your code look a little cleaner.
 
Awesome, I'm trying it out right now. The only thing now is that I'm getting a "Run-time error '94': Invalid use of Null" error on the line
Code:
cgooff = Me.PalletTrainOff

I think it is because it's already associating Me.PalletTrainOff is Null. I think that some of these might need to be ElseIf's...I'll keep plugging away... Thank you once again...it does look A LOT cleaner!
 
I wanted to say a big thank you for pointing me in the right direction with the "IsNull" and "AND" syntax's.

The end result code looks something like this:
Code:
Private Sub UpdateMissionRemarks_Click()
    Dim rmk As String: rmk = ""

    If Me.CustomsOnly = True Then
            rmk = "CUSTOMS ONLY"
        Else
    End If
    If Me.CargoOffloadBDSC = True Then
        If IsNull(Me.RollingOff) And IsNull(Me.PalletOff) And IsNull(Me.PalletTrainOff) Then
            rmk = "UNKNOWN CARGO OFF"
        ElseIf IsNull(Me.RollingOff) And IsNull(Me.PalletOff) And (IsNull(Me.PalletTrainOff) = False) Then
            rmk = Me.PalletTrainOff & " OFF"
        ElseIf IsNull(Me.RollingOff) And (IsNull(Me.PalletOff) = False) And IsNull(Me.PalletTrainOff) Then
            rmk = Me.PalletOff & "$ OFF"
        ElseIf IsNull(Me.RollingOff) And (IsNull(Me.PalletOff) = False) And (IsNull(Me.PalletTrainOff) = False) Then
            rmk = Me.PalletOff & "$" & " " & Me.PalletTrainOff & " OFF"
        ElseIf (IsNull(Me.RollingOff) = False) And IsNull(Me.PalletOff) And (IsNull(Me.PalletTrainOff) = False) Then
            rmk = Me.RollingOff & "xRSS" & " " & Me.PalletTrainOff & " OFF"
        ElseIf (IsNull(Me.RollingOff) = False) And IsNull(Me.PalletOff) And IsNull(Me.PalletTrainOff) Then
            rmk = Me.RollingOff & "xRSS OFF"
        ElseIf (IsNull(Me.RollingOff) = False) And (IsNull(Me.PalletOff) = False) And IsNull(Me.PalletTrainOff) Then
            rmk = Me.RollingOff & "xRSS" & " " & Me.PalletOff & "$ OFF"
        Else
            rmk = Me.RollingOff & "xRSS" & " " & Me.PalletOff & "$" & " " & Me.PalletTrainOff & " OFF"
        End If
    Else
    End If
    If Me.PassengersOffloadBDSC = True Then
        If IsNull(Me.PassengersOffQuantity) Then
            If Me.CargoOffloadBDSC = True Then
                rmk = rmk & " // " & "UNKNOWN PAX OFF"
            Else
                rmk = "UNKNOWN PAX OFF"
            End If
        Else
            If Me.CargoOffloadBDSC = True Then
                rmk = rmk & " // " & Me.PassengersOffQuantity & " PAX OFF"
            Else
                rmk = Me.PassengersOffQuantity & " PAX OFF"
            End If
        End If
    Else
    End If
    If (Me.VIP_DV = True) And (Me.VIP_DVOff = True) Then
        If IsNull(Me.DVTotalNumber) Then
            rmk = rmk & " // " & "UNKNOWN DV OFF"
        Else
            rmk = rmk & " // " & Me.DVTotalNumber & "xDV OFF"
        End If
    Else
    End If
    If (Me.Explosives = True) And (Me.ExplosivesOff = True) Then
        rmk = rmk & " // " & Me.HighestClassOff & " (" & Me.NEWOff & ") OFF"
    Else
    End If
    If Me.CargoThru = True Then
        rmk = rmk & vbCrLf & "CARGO THRU"
    Else
    End If
    If Me.PassengersThruload = True Then
        If Me.CargoThru = True Then
            rmk = rmk & " // PAX THRU"
        Else
            rmk = rmk & vbCrLf & "PAX THRU"
        End If
    Else
    End If
    If (Me.VIP_DV = True) And (Me.VIP_DVThru = True) Then
        If Me.CargoThru = True Then
            rmk = rmk & " // DV THRU"
        Else
            rmk = rmk & vbCrLf & "DV THRU"
        End If
    Else
    End If
    If (Me.Explosives = True) And (Me.ExplosivesThru = True) Then
        If Me.CargoThru = True Then
            rmk = rmk & " // " & Me.HighestClassThru & " (" & Me.NEWThru & ") THRU"
        Else
            rmk = rmk & vbCrLf & Me.HighestClassThru & " (" & Me.NEWThru & ") THRU"
        End If
    Else
    End If
    If Me.CargoOnloadBDSC = True Then
        If IsNull(Me.RollingOn) And IsNull(Me.PalletOn) And IsNull(Me.PalletTrainOn) Then
            rmk = rmk & vbCrLf & "UNKNOWN CARGO ON"
        ElseIf IsNull(Me.RollingOn) And IsNull(Me.PalletOn) And (IsNull(Me.PalletTrainOn) = False) Then
            rmk = rmk & vbCrLf & Me.PalletTrainOn & " ON"
        ElseIf IsNull(Me.RollingOn) And (IsNull(Me.PalletOn) = False) And IsNull(Me.PalletTrainOn) Then
            rmk = rmk & vbCrLf & Me.PalletOn & "$ ON"
        ElseIf IsNull(Me.RollingOn) And (IsNull(Me.PalletOn) = False) And (IsNull(Me.PalletTrainOn) = False) Then
            rmk = rmk & vbCrLf & Me.PalletOn & "$" & " " & Me.PalletTrainOn & " ON"
        ElseIf (IsNull(Me.RollingOn) = False) And IsNull(Me.PalletOn) And (IsNull(Me.PalletTrainOn) = False) Then
            rmk = rmk & vbCrLf & Me.RollingOn & "xRSS" & " " & Me.PalletTrainOn & " ON"
        ElseIf (IsNull(Me.RollingOn) = False) And IsNull(Me.PalletOn) And IsNull(Me.PalletTrainOn) Then
            rmk = rmk & vbCrLf & Me.RollingOn & "xRSS ON"
        ElseIf (IsNull(Me.RollingOn) = False) And (IsNull(Me.PalletOn) = False) And IsNull(Me.PalletTrainOn) Then
            rmk = rmk & vbCrLf & Me.RollingOn & "xRSS" & " " & Me.PalletOn & "$ ON"
        Else
            rmk = rmk & vbCrLf & Me.RollingOn & "xRSS" & " " & Me.PalletOn & "$" & " " & Me.PalletTrainOn & " ON"
        End If
    Else
    End If
    If Me.PassengersOnloadBDSC = True Then
        If IsNull(Me.PassengersOnQuantity) Then
            If Me.CargoOnloadBDSC = True Then
                rmk = rmk & " // " & "UNKNOWN PAX ON"
            Else
                rmk = rmk & vbCrLf & "UNKNOWN PAX ON"
            End If
        Else
            If Me.CargoOnloadBDSC = True Then
                rmk = rmk & " // " & Me.PassengersOnQuantity & " PAX ON"
            Else
                rmk = rmk & vbCrLf & Me.PassengersOnQuantity & " PAX ON"
            End If
        End If
    Else
    End If
    If (Me.VIP_DV = True) And (Me.VIP_DVOn = True) Then
        If IsNull(Me.DVQtyOn) Then
            If Me.CargoOnloadBDSC = True Then
                rmk = rmk & " // " & "UNKNOWN DV ON"
            Else
                rmk = rmk & vbCrLf & "UNKNOWN DV ON"
            End If
        Else
            If Me.CargoOnloadBDSC = True Then
                rmk = rmk & " // " & Me.DVQtyOn & "xDV ON"
            Else
                rmk = rmk & vbCrLf & Me.DVQtyOn & "xDV ON"
            End If
        End If
    Else
    End If
    If (Me.Explosives = True) And (Me.ExplosivesOn = True) Then
        If Me.CargoOnloadBDSC = True Then
            rmk = rmk & " // " & Me.HighestClassOn & " (" & Me.NEWOn & ") ON"
        Else
            rmk = rmk & vbCrLf & Me.HighestClassOn & " (" & Me.NEWOn & ") ON"
        End If
    Else
    End If
    
    Me.CargoRemarks = (rmk)

And it's working pretty well. :D:D If anyone can see anything that I'm overlooking, I'm more than open to the information as I'm still pretty new to this.
 
I wanted to say a big thank you for pointing me in the right direction
Due to a bug in the forum software this message was "unapproved" (hidden) for some considerable time. I have just approved it. I hope no one has been inconvenience too much! The new forum software no longer has this bug, so this problem should not reoccur.
 

Users who are viewing this thread

Back
Top Bottom