Please look at this Boolean Vs String

mr moe

Registered User.
Local time
Today, 18:44
Joined
Jul 24, 2003
Messages
332
I'm working on a software that was developed by someone who left the company. The problem is that the software works for all locations execpt one that is in austria, after debuging I found out that there is a statement in the code that uses boolean true or false, the only way it worked is when I put an if statement with false or true as string, ex: if doc = "true" then
buttom line has anyone faced this problem, I searched microsoft website and they said that some vb engines don't convert boolean to string. Please Please if someone has a clue try to help. Thanks.
 
Yes, if the version of Access is in another natural language other than English this can happen.

For instance; in the Dutch version a Boolean –1 (True) would convert to Waar. This is OK as far as a string build is concerned but it would not execute as an SQL string because the SQL parser expects English.

So if the following code was called with blnState set to True it would evaluate to True in Englist and Waar in Dutch. The best fix seems to be to convert blnState back to its numerical value using the Cint() function.

Code:
[color=green]'   The line of code..." SET FileExists = " & CInt(blnState)
'   overrides the Dutch interpretation of 'True' and 'False'.[/color]
Public Function UpdateFileExists(ByVal strFilePath As String, _
                                 ByVal strFileName As String, _
                                 ByVal blnState As Boolean) As Boolean
    
    If (conHandleErrors) Then On Error GoTo ErrorHandler
       
    [color=green]'  Update all matching records with blnState.[/color]
    CurrentDb.Execute " UPDATE tblRecentFiles" & _
                      " SET FileExists = " & CInt(blnState) & _
                      " WHERE FileName = " & Chr$(34) & strFileName & Chr$(34) & _
                      " AND FilePath = " & Chr$(34) & strFilePath & Chr$(34)
    
    UpdateFileExists = True
    
ExitProcedure:
    Exit Function

ErrorHandler:
    UpdateFileExists = False
    DisplayError "Function UpdateFileExists"
    
    Resume ExitProcedure
 
End Function

Yes I have been caught and so hope that helps.

Regards,
Chris.
 
What's the code?

Seth
 
Chris, thanks for the help. Actually the code is built in vb6 and compiled to dll, this is a customized visio application that uses the dll. Here is the old code "like I said it worked for all locations execpt Austria" it's something like that.
somwhere inside the code, remember Status is boolean.

Shapes("Status").Cells(my_stat).Formula = somedoc.Status

whenver .status was false or true the code was stopping and not reading, i had to do it this way to make it work.

if somedoc.status = false then
Shapes("Status").Cells(my_stat).Formula = "False"
Else
Shapes("Status").Cells(my_stat).Formula = "True"
end if

Thanks for the help. Please let me know if you can suggest anything.
 
This is almost total airware but did you try: -

Shapes("Status").Cells(my_stat).Formula = CInt(somedoc.status)

No way can I test it but hope that works.

Regards,
Chris.
 

Users who are viewing this thread

Back
Top Bottom