Ms-access localization and boolean defaults

Our access client generates on-the-fly SQL inserts, update and removal instructions that must be sent to the MS-SQL server. Most users have Access 2007, and some use the full version of MS-Access, 2003 or 2007. This morning, one of our new users abroad, using the French / full version of Access 2003, was unable to update data containing Boolean fields.

It appears that these fields in the French version of Access are filled with "Vrai / Faux" instead of "True / False". The problem was resolved by setting the Access 2007 runtime.

But I would like to find a permanent solution where I could read from somewhere, where the localized version of Access is used, and "translate" the localized True / False values ​​to standard True / False. I already checked the regional settings of the computer without success, so this is somewhere else. Any idea?

EDIT: after JohnFX's suggestion, you can effectively convert from local True / False to universal True / False with this simple function:

Function xBoolean(xLocalBooleanValue) as Boolean
if cint(xLocalBooleanValue) = -1 Then
    xBoolean = True
endif
if cint(xLocalBooleanValue) = 0 Then
    xBoolean = False
endif
end function

EDIT: after @David's comments, I changed my favorites solution. His proposal is smarter than mine.

EDIT: I get the Vrai / Faux values ​​by reading the field value in the recordset:

? debug.print screen.activeForm.recordset.fields(myBooleanField).value 
Vrai
+3
source share
3 answers

True , 0, , .

, True NOT 0 False = 0, Access ( , VBA Jet Access True/False), , .

, . ODBC ADO , , , , .

, /, NOT 0 = 0 True False, .

EDIT: , :

, ? , ? Null, CInt(), CInt() Null.

, , VBA , 0, True. . :

  Function xBoolean(xLocalBooleanValue As Vriant) as Boolean
    If CInt(xLocalBooleanValue) <> 0 Then
       xBoolean = True
    End If
  End Function

, :

  Function xBoolean(xLocalBooleanValue As Variant) as Boolean
    xBoolean = (CInt(xLocalBooleanValue) <> 0)
  End Function

, :

  Function xBoolean(xLocalBooleanValue As Variant) as Boolean
    xBoolean = (CInt(Nz(xLocalBooleanValue, 0)) <> 0)
  End Function

, , , , , - , , , , , , , .

?

- , .

( , , , )

+2

-1/0 (Access is weird about booleans) true/false ?

- , .

, , ?

+1

Plain:

Function xBoolean(bool As Variant) As Boolean
    xBoolean = Abs(Nz(bool, 0))
End Function
0
source

Source: https://habr.com/ru/post/1719383/


All Articles