Results 1 to 6 of 6
  1. #1
    asearle is offline Novice
    Windows XP Access 2003
    Join Date
    Jul 2010
    Posts
    24

    True, "Wahr" and -1 / 0

    Hi Everyone,

    I am using VBA to build an INSERT statement which I then execute and which works fine under English ...

    INSERT INTO tbl_Registration (MyTrueFalseField)
    VALUES (" & Me.TrueFalseField & ")"

    The SQL-String writes True into the table.

    But if I run this under German MS-Access, it tries to write Wahr , the German word for True and so falls over.

    I would therefore like to get the system to write -1 or 0 instead of True/False and so am wondering how I can easily do this.

    Of course I can use an Iif or if-clause to flip this manually but that seems very clunky.

    I've googled and searched on the format() function but cannot find anything on True/False. My hope here would be to find syntax to easily switch the values True/False to -1 or 0.

    Many thanks on any tips that you can give me.



    Regards,
    Alan

  2. #2
    Join Date
    Jun 2010
    Location
    Belgium
    Posts
    1,170
    Hi,

    I suppose the TrueFalseField on the form is an unbound control, so the application reads it as a textfield. You could try to use the conversion function CBool.

    like
    strSQL = "INSERT INTO tbl_Registration (MyTrueFalseField) VALUES (" & CBool(Me.TrueFalseField) & ")"

    If that doesn't work you can try to force the value to -1/0 by the IIf function:
    Iif(Me.TrueFalseField = 'Wahr',-1,0)

  3. #3
    asearle is offline Novice
    Windows XP Access 2003
    Join Date
    Jul 2010
    Posts
    24

    CBool

    Many thanks for this tip and, yes, I gave CBool a try and it worked fine under English returning the value True. But under German it returned the value Wahr and fell over again.

    I have tried experimenting with formatting (e.g. format(Me.MyTrueFalseField, "#") ) but these experiments didn't bear fruit.

    So, yes, it looks like I will have to resort to an if or an iif clause which is a bit irritating because, if at any point the system is used under another language version (e.g. Spanish), then the problem will reoccur with whatever word is Spanish for True.

    I'll continue investigating and will give feedback if I find a solution.

    But many thanks for the tips.

    Regards,
    Alan

  4. #4
    Join Date
    Jun 2010
    Location
    Belgium
    Posts
    1,170
    Hi,

    maybe you can try CInt to force it to a number format?

    grNG

  5. #5
    asearle is offline Novice
    Windows XP Access 2003
    Join Date
    Jul 2010
    Posts
    24

    Fantastic

    Hi Noella,

    Fantastic, thanks. It worked fine.

    But I'm a bit ashamed that I didn't think of that :-/

    Many thanks for your lateral thinking :-)

    Regards,
    Alan

  6. #6
    weekend00 is offline I may not be right
    Windows XP Access 2003
    Join Date
    Aug 2010
    Posts
    1,295
    The value save in the Yes/No field in the table is only 0 or -1, there is no "YES", "NO", "TRUE", "FALSE" or "Warh" save in the table, you see these words because 0 or -1 were presented as these words.

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

Similar Threads

  1. Replies: 3
    Last Post: 04-10-2010, 10:22 AM
  2. Replies: 21
    Last Post: 06-03-2009, 05:54 PM
  3. aSTR = Dir("C:\*.*") >> "Type Mismatch"
    By JGrant in forum Programming
    Replies: 1
    Last Post: 03-28-2009, 05:17 AM
  4. Replies: 2
    Last Post: 08-31-2006, 12:19 PM
  5. "Count" and "Countif" in Reports
    By JMantei in forum Reports
    Replies: 1
    Last Post: 06-20-2006, 02:20 PM

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