Skip to content

Instantly share code, notes, and snippets.

@Phuseos
Created September 6, 2016 07:13
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Phuseos/13b5a4a34b6f4e0b5b489a152bcffb57 to your computer and use it in GitHub Desktop.
Save Phuseos/13b5a4a34b6f4e0b5b489a152bcffb57 to your computer and use it in GitHub Desktop.
Translate JetSQL to SQL (VBA)
Public Function TranslateToSQL(ByVal jSQL As String) As String
If (Application.CurrentProject.ProjectType = acADP) Then
' Operators, constants, delimiters and wildcard characters
jSQL = Replace$(jSQL, "#", "'")
jSQL = Replace$(jSQL, """", "'")
jSQL = Replace$(jSQL, "&", "+")
jSQL = Replace$(jSQL, "?", "_")
jSQL = Replace$(jSQL, "*", "%")
jSQL = Replace$(jSQL, "True", "-1")
jSQL = Replace$(jSQL, "False", "0")
' correct SELECT * FROM and SELECT <table>.* FROM
jSQL = Replace$(jSQL, ".% ", ".* ")
jSQL = Replace$(jSQL, ".%,", ".*,")
jSQL = Replace$(jSQL, " % ", " * ")
' correct SELECT COUNT(*)
jSQL = Replace$(asSQL, "(%)", "(*)")
Else
' Correctie voor ABS(TRUE)
jSQL = Replace$(asSQL, "ABS(True)", "True")
End If
TranslateToSQL = jSQL
End Function
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment