Results 1 to 6 of 6
  1. #1
    alcorp is offline Novice
    Windows 7 64bit Access 2010 64bit
    Join Date
    Nov 2013
    Posts
    12

    Question Appending leading zeros by if statement with formulas for true and false, in SQL

    My first question is how do I append 00001 so I can have a value for the false side of 9123400001 instead of 912341



    My second question is why does it prompt me to enter parameters? It also produces all false values from the if statement

    What I am trying to do is use a column that has either a Y or a N and using the if statement to correspond with different formulas depending on the Y or N.

    If anyone can help, thanks!

    This what I have so far.
    SELECT

    IIF (ISRAILROAD=Y,9 & UCN & TXRTAREA, 9 & UCN & 00001 )

    FROM CombinedUtility;

  2. #2
    pbaldy's Avatar
    pbaldy is offline Who is John Galt?
    Windows XP Access 2007
    Join Date
    Feb 2010
    Location
    Nevada, USA
    Posts
    22,521
    Try

    IIF (ISRAILROAD=-1,9 & UCN & TXRTAREA, 9 & UCN & "00001" )

    If you still get a parameter prompt, what is it for? That is Access telling you it can't find something.
    Paul (wino moderator)
    MS Access MVP 2007-2019
    www.BaldyWeb.com

  3. #3
    thebigthing313 is offline Competent Performer
    Windows 7 64bit Access 2010 64bit
    Join Date
    Jan 2014
    Posts
    119
    In CombinedUtility, you have a field called IsRailroad. Is this a Boolean field, as in Yes/No (True or False)? Or is it a text field where you actually typed in Y or N?

    If it's a boolean field, then your Iif function's first argument should be ISRAILROAD = TRUE.
    If it's a text field containing either Y or N, then it should be ISRAILROAD = "Y".

    As for the parameters, what is it asking for? Most likely reason is you mistyped a field name in your SQL code.

  4. #4
    alcorp is offline Novice
    Windows 7 64bit Access 2010 64bit
    Join Date
    Nov 2013
    Posts
    12
    When I run it it prompts me the parameters just for ISRAILROAD, which is a text filed column too. I also found the column name is IS RAILROAD. I tried eliminating the space in between in between and when I do I just it produces an error for the query.

  5. #5
    alcorp is offline Novice
    Windows 7 64bit Access 2010 32bit
    Join Date
    Nov 2013
    Posts
    12
    Okay I got it, Thanks!

  6. #6
    thebigthing313 is offline Competent Performer
    Windows 7 64bit Access 2010 64bit
    Join Date
    Jan 2014
    Posts
    119
    Glad you got it sorted out. Good luck with the rest of your project!

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

Similar Threads

  1. Replies: 2
    Last Post: 10-29-2012, 11:28 AM
  2. Replies: 7
    Last Post: 01-11-2012, 12:24 PM
  3. Leading Zeros
    By dirtbiker1824 in forum Access
    Replies: 1
    Last Post: 03-14-2011, 02:16 PM
  4. Adding Leading Zeros
    By jo15765 in forum Access
    Replies: 13
    Last Post: 11-20-2010, 11:11 PM
  5. leading 'Zeros' in data
    By wasim_sono in forum Forms
    Replies: 3
    Last Post: 04-06-2009, 11:57 AM

Tags for this Thread

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