Option Explicit
Option Compare Text
Private Sub Form_Load()
Dim srtSQL As String
[color=green]' Set Function IsLoaded() to return type as Boolean[/color]
srtSQL = "WHERE MyBooleanField = " & IsLoaded(Me.Name)
[color=green]' What do you get?[/color]
MsgBox srtSQL [color=green]' WHERE MyBooleanField = True[/color]
[color=green]' Set Function IsLoaded() to return type as Integer[/color]
srtSQL = "WHERE MyBooleanField = " & IsLoaded(Me.Name)
[color=green]' What do you get?[/color]
MsgBox srtSQL [color=green]' WHERE MyBooleanField = -1[/color]
[color=green]' Now give that code to someone running, for example, the Dutch version of Access.
' Set Function IsLoaded() to return type as Boolean[/color]
srtSQL = "WHERE MyBooleanField = " & IsLoaded(Me.Name)
[color=green]' What do you get?[/color]
MsgBox srtSQL [color=green]' WHERE MyBooleanField = Waar[/color]
[color=green]' Set Function IsLoaded() to return type as Integer[/color]
srtSQL = "WHERE MyBooleanField = " & IsLoaded(Me.Name)
[color=green]' What do you get?[/color]
MsgBox srtSQL [color=green]' WHERE MyBooleanField = -1[/color]
[color=green]' The point is that the string: -
' WHERE MyBooleanField = Waar
' can't be used within an SQL string because SQL strings require English not Dutch.
' So the one that fails is when the return value is set to the Boolean value, meaning: -
' Public Function IsLoaded(ByVal strFormName As String) As Boolean
' will fail if the return data type as 'True' or 'False' is interpreted by the
' language version as anything other than 'True' or 'False', as in this case
' the Dutch version as 'Waar' or 'Onwaar', respectively.
'
' But: -
' Public Function IsLoaded(ByVal strFormName As String) As Integer
' returns to the SQL string, in this case, 'WHERE MyBooleanField = -1'
' That survives the natural language interpretation because -1 and 0 are
' understood by SQL.
'
' Please don't use a return type as Boolean unless you are prepared for the worst
' debugging session you ever came across, and incidentally, can't see.[/color]
End Sub