Results 1 to 4 of 4
  1. #1
    JackieEVSC is offline Advanced Beginner
    Windows 7 32bit Access 2007
    Join Date
    Oct 2011
    Posts
    70

    IIF error/question

    I have a database that pulls from a SQL database, an IBM mainframe database, and the access database. I work for a large school corporation that separated one school into two separate locations this year. The information we for school location use is pulled from the SQL database which does not distinguish between the two different locations. For financial reasons, we cannot add another location to the SQL database (third party app where our price is by the number of locations).

    We have netbooks for all students grades six through twelve which are checked out to them using the SQL (library system) database. The database I wrote creates barcoded repair tickets when they are sent in for repair, and we have no way of knowing which location to return units to if they are sent from those two schools.

    I created an option group to select which location they are at so that it will print on the repair ticket, but I cannot get it to work correctly. I need it to say " – 1st Ave" for option 1, " – Diamond" for option 2, or nothing if an option is not selected (it will only be selected on those two schools, not the other 21 schools that check out technology to kids). The option selection is stored in the "A_Location" field in the tbl_RepairInfo table.

    Below is the code I have on the form, but it returns "Error#". It's obviously a syntax error, but I have no idea what I'm doing wrong. Can someone please point out my error? Thanks in advance for your help!



    =IIf([A_Location]=1," - 1st Ave",IIf([A_Location]=2," - Diamond",""))

  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
    I don't see any obvious errors. The field name has an underscore rather than a space? That field is part of the record source of the form?
    Paul (wino moderator)
    MS Access MVP 2007-2019
    www.BaldyWeb.com

  3. #3
    JackieEVSC is offline Advanced Beginner
    Windows 7 32bit Access 2007
    Join Date
    Oct 2011
    Posts
    70
    I figured it out by using =Choose(Nz([A_Location],0)," - 1st Ave"," - Diamond")

  4. #4
    Missinglinq's Avatar
    Missinglinq is offline VIP
    Windows 7 64bit Access 2007
    Join Date
    May 2012
    Location
    Richmond (Virginia, not North Yorkshire!)
    Posts
    3,018
    Glad you got it fixed, although, with the Option Group named A_Location, the code worked correctly, for me, with the Control Source of the Textbox set to

    Code:
    =IIf([A_Location]=1," - 1st Ave",IIf([A_Location]=2," - Diamond",""))


    At any rate, need to add a third Option for 'other.' The problem is that you cannot 'reset' an Option back to Null once a selection has been made. If the user selects one of the two current Options and then realize that neither is correct, they cannot simply 'untick' it! A third Option, with a corresponding Null or "" being assigned to the Textbox would cover that possibility.

    Linq ;0)>
    The problem with making anything foolproof...is that fools are so darn ingenious!

    All posts/responses based on Access 2003/2007

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

Similar Threads

  1. Question: SigmaPlot macro syntax error
    By Captain Database ...!! in forum Import/Export Data
    Replies: 2
    Last Post: 03-27-2012, 10:04 AM
  2. Replies: 4
    Last Post: 03-26-2012, 12:45 PM
  3. Replies: 1
    Last Post: 01-11-2012, 06:41 PM
  4. Replies: 1
    Last Post: 11-30-2011, 01:13 AM
  5. Erroneous Error Question
    By Simple in forum Access
    Replies: 5
    Last Post: 11-28-2009, 04:39 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