Erorr in code Convert Text

AHMEDRASHED

Member
Local time
Today, 23:37
Joined
Feb 2, 2020
Messages
59

Hello , I have Form to convert ,

Example to convert :

05JAN ARNCDG (D)10JAN CDGARN (I)
06JAN DXBBEY (Q)04APR BEYDXB (Q)
19JAN BEYRUH (K)

Example Result :
STOCKHOLM-PARIS-STOCKHOLM DATED ON 05JAN-10JAN
DUBAI-BEIRUT-DUBAI DATED ON 06JAN -04APR
BEIRUT-RIYADH DATED 19JAN

i got this erorr : any help please

1677404067774.png


Module code :

Public Function ConvertFlight(flightText As String) As String
' Split the flight text into its parts
Dim parts() As String
parts = Split(flightText, " ")

' Look up the city names based on the IATA codes
Dim depCity As String
Dim arrCity As String

depCity = DLookup("City", "tblAirport", "IATA Code = '" & Left(parts(1), 3) & "'")
arrCity = DLookup("City", "tblAirport", "IATA Code = '" & Mid(parts(1), 4, 3) & "'")

' Create the converted text
ConvertFlight = depCity & "-" & arrCity & " dated on " & parts(0) & " - " & Mid(parts(2), 1, Len(parts(2)) - 1)
End Function


CmdConvert_Click code :
Private Sub CmdConvert_Click()
Dim flightText As String
Dim convertedText As String

flightText = Me.inputText.Value
convertedText = ConvertFlight(flightText)

Me.OutputText.Value = convertedText
End Sub
 

Attachments

  • convert.accdb
    convert.accdb
    980 KB · Views: 134
  • 1677403722390.png
    1677403722390.png
    26.7 KB · Views: 91
Your Module is named the same as your function (ConvertFlight). Change one, I suggest renaming the module, it only has to be done in one place.
 
don't Name your Module, same name as your Function.
also there is error on your Dlookup().
 

Attachments

Users who are viewing this thread

Back
Top Bottom