Erorr in code Convert Text (1 Viewer)

AHMEDRASHED

Member
Local time
Today, 17:17
Joined
Feb 2, 2020
Messages
50

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
    980 KB · Views: 71
  • 1677403722390.png
    1677403722390.png
    26.7 KB · Views: 49

plog

Banishment Pending
Local time
Today, 09:17
Joined
May 11, 2011
Messages
11,646
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.
 

arnelgp

..forever waiting... waiting for jellybean!
Local time
Today, 22:17
Joined
May 7, 2009
Messages
19,245
don't Name your Module, same name as your Function.
also there is error on your Dlookup().
 

Attachments

  • convert.accdb
    980 KB · Views: 70

Users who are viewing this thread

Top Bottom