George-Bowyer
Registered User.
- Local time
- Today, 11:34
- Joined
- Dec 21, 2012
- Messages
- 178
Hi,
I have the following function in my "General" Module
(It's not code that I wrote myself - and I can't even remember where I got it from).
On my laptop, using Office365, it compiles fine when I click debug on the module.
However, on my client's system the line <<Dim LongLong As Integer>> throws up a syntax error.
I presume that at one point LongLong was being dim'ed as a long, but I have no idea who changed that or when.
I am using Access from Office365 - the client is using Access 2019
Any tips on how to resolve the compilation problem on the client's setup, please?
I have the following function in my "General" Module
(It's not code that I wrote myself - and I can't even remember where I got it from).
Public Function CSql( _
ByVal Value As Variant) _
As String
Const vbLongLong As Integer = 20
Const SqlNull As String = "Null"
Dim Sql As String
Dim LongLong As Integer
#If Win32 Then
LongLong = vbLongLong
#End If
#If Win64 Then
LongLong = VBA.vbLongLong
#End If
Select Case VarType(Value)
Case vbEmpty ' 0 Empty (uninitialized).
Sql = SqlNull
Case vbNull ' 1 Null (no valid data).
Sql = SqlNull
Case vbInteger ' 2 Integer.
Sql = Str(Value)
Case vbLong ' 3 Long integer.
Sql = Str(Value)
Case vbSingle ' 4 Single-precision floating-point number.
Sql = Str(Value)
Case vbDouble ' 5 Double-precision floating-point number.
Sql = Str(Value)
Case vbCurrency ' 6 Currency.
Sql = Str(Value)
Case vbDate ' 7 Date.
Sql = Format(Value, " \#yyyy\/mm\/dd hh\:nn\:ss\#")
If DateValue(Value) = Value Then
Sql = Format$(Value, "\#mm\/dd\/yyyy\#")
Else
Sql = Format$(Value, "\#mm\/dd\/yyyy hh\:nn\:ss\#")
End If
Case vbString ' 8 String.
Sql = Replace(Trim(Value), "'", "''")
If Sql = "" Then
Sql = SqlNull
Else
Sql = " '" & Sql & "'"
End If
Case vbObject ' 9 Object.
Sql = SqlNull
Case vbError ' 10 Error.
Sql = SqlNull
Case vbBoolean ' 11 Boolean.
Sql = Str(Abs(Value))
Case vbVariant ' 12 Variant (used only with arrays of variants).
Sql = SqlNull
Case vbDataObject ' 13 A data access object.
Sql = SqlNull
Case vbDecimal ' 14 Decimal.
Sql = Str(Value)
Case vbByte ' 17 Byte.
Sql = Str(Value)
Case LongLong ' 20 LongLong integer (Valid on 64-bit platforms only).
Sql = Str(Value)
Case vbUserDefinedType ' 36 Variants that contain user-defined types.
Sql = SqlNull
Case vbArray ' 8192 Array.
Sql = SqlNull
Case Else ' Should not happen.
Sql = SqlNull
End Select
CSql = Trim(Sql)
End Function
On my laptop, using Office365, it compiles fine when I click debug on the module.
However, on my client's system the line <<Dim LongLong As Integer>> throws up a syntax error.
I presume that at one point LongLong was being dim'ed as a long, but I have no idea who changed that or when.
I am using Access from Office365 - the client is using Access 2019
Any tips on how to resolve the compilation problem on the client's setup, please?
Last edited: