Results 1 to 6 of 6
  1. #1
    draxdeveloper is offline Novice
    Windows 7 32bit Access 2010 32bit
    Join Date
    Apr 2016
    Posts
    4

    Bollean problems

    Hello, i am making a code using VBA into access 2010.
    I am making a search code, that get data from a form and create a select using this data to search a register in a table.
    Ok, the problem is in a combo box that have the options yes and no that return 1 and 0, i can make VBA understand that this a boll Variable, but since my access is in Portuguese instead of returning "True" or "False" it's is returning "Verdadeiro" or "Falso" (it's the translation of true and false).
    The problem is that it's creating the string that i an using to create the SELECT with "Verdadeiro" or with "Falso" and since SQL don't recognize this my code it's not working.

    In other words, the Access (or the VBA) is translating the booleans values to the language that access it's installed (in this case, into portuguese).
    Someone have seem something like that before? I have no idea what to do and i searched all the web for a solution, if i can't solve this i will have to change my boolean values to small int and do a lot of workarounds





  2. #2
    ranman256's Avatar
    ranman256 is online now VIP
    Windows Vista Access 2010 32bit
    Join Date
    Apr 2014
    Location
    Kentucky
    Posts
    9,549
    Booleans do not return "True", it returns TRUE. True is not a string, it's a value. Do not use strings.
    i would think FALSO =0. (Again,not the string)

    if not, then set the combo box to VALUES,with 2 columns: 1 string, 1 numeric
    "FALSO", 0
    "verd",-1

    set bound column to 2 and the combo will deliver true/false values.

  3. #3
    orange's Avatar
    orange is online now Moderator
    Windows 8 Access 2010 32bit
    Join Date
    Sep 2009
    Location
    Ottawa, Ontario, Canada; West Palm Beach FL
    Posts
    16,849
    VBA booleans -1 True 0 False

    I'm not sure about True/False in other languages.

    You might want to tell us WHAT your search is about, the subjects involved. It seems you have focused on How you will represent something..

  4. #4
    draxdeveloper is offline Novice
    Windows 7 32bit Access 2010 32bit
    Join Date
    Apr 2016
    Posts
    4
    Well, in the table i created a "yes/no" column as a "true/false".

    I an creating a database to a archive in my work, there some fields like revised that says if a file was revised.
    In the form this fields are represented by a combo box with yes and no.
    Then i created a var As a Boolean and created a string that create a SELECT using WHERE field = value, if the user have write something (or selected, in the case of a combo box).
    It's working in the rest of the form, except with those combo box because when i use Me.field_name.Value it's return Verdadeiro.
    I am using MsgBox to see what VBA is writing in the Query String, and like i said it's returning Verdadeiro (or Falso) and not True.
    If i write a SQL Query in access using WHERE field = True the query works, but if i use WHERE field = Verdadeiro the Query just don't work. (and it's expected)

  5. #5
    draxdeveloper is offline Novice
    Windows 7 32bit Access 2010 32bit
    Join Date
    Apr 2016
    Posts
    4
    and the var that receive the value of the combo box it's set as a Boolean, even if i explicit write true (without "") VBA just translates as Verdadeiro. Here:
    If (Not IsNull(Me.selecao_revisado.Value) And primeiro = False) Then
    prateleira = Me.selecao_revisado.Value
    stringBusca = stringBusca & "assentamentosFuncionais.[revisado]=" & revisado
    primeiro = True

    ElseIf (Not IsNull(Me.selecao_revisado.Value) And primeiro = True) Then
    prateleira = Me.selecao_revisado.Value
    stringBusca = stringBusca & " AND " & "assentamentosFuncionais.[revisado]=" & revisado

    This is the code part with problems.
    Now, StringBusca it's the same as StringSearch and it's the string that creates the Query, the query it's working since it was working with the rest of the form.

    Here is how i set revisado: Dim revisado As Boolean

    Even if i write:
    stringBusca = stringBusca & "assentamentosFuncionais.[revisado]=" & True
    i still get Verdadeiro

  6. #6
    draxdeveloper is offline Novice
    Windows 7 32bit Access 2010 32bit
    Join Date
    Apr 2016
    Posts
    4
    And i am not using the string, i setted the value 0 and 1. I tried -1 and 0 and i having the same issue with both. It's translates true and false value

Please reply to this thread with any new information or opinions.

Similar Threads

  1. Two Problems
    By IannWard in forum Forms
    Replies: 3
    Last Post: 03-23-2014, 11:23 PM
  2. IIF Problems
    By suverman in forum Queries
    Replies: 3
    Last Post: 05-23-2011, 02:22 AM
  3. problems please help
    By stryder09 in forum Access
    Replies: 1
    Last Post: 02-15-2011, 02:24 PM
  4. Several problems
    By Bergh in forum Access
    Replies: 1
    Last Post: 05-30-2010, 03:56 AM
  5. OLE problems how to fix
    By miziri in forum Access
    Replies: 7
    Last Post: 04-29-2010, 06:18 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Other Forums: Microsoft Office Forums