Results 1 to 3 of 3
  1. #1
    timmygrover is offline Novice
    Windows Vista Access 2003
    Join Date
    Dec 2011
    Posts
    26

    Outputting proper grammar . . .

    So I'm using a nested IIF statement to get a/an from a query.



    Paragraph2: IIF([Paragraph3] LIKE "A*", "an ", IIF([Paragraph3] LIKE "E*", "an ", IIF([Paragraph3] LIKE "I*", "an ", IIF([Paragraph3] LIKE "O*", "an ",
    IIF([Paragraph3] LIKE "U* ", "an ", IIF([Paragraph3] LIKE "Y*", "an ", "a "))))))

    The thing is, that it's working ALMOST all the time, if Paragraph 3 begins with a vowel, it always outputs "an " but if it begins with a consonant it returns "a " about 80% of the time. Why in the world would it ALMOST always work?

    Note: [Paragraph3] has it's own IIF statement based on a RND() integeger (if RND()=X, return Sentence1, if RND()=Y, return Sentence2

    I don't know if that has anything to do with it
    Thanks!

  2. #2
    June7's Avatar
    June7 is offline VIP
    Windows XP Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    53,621
    RND is a randomize function. You want random values? Are X and Y representing field names?

    Can shorten the expression.
    Paragraph2: IIF([Paragraph3] LIKE "[A,E,I,O,U,Y]*", "an ", "a ")

    Isn't Y only sometimes a vowel and when would it go with 'an' - "tie a yellow ribbon" ?

    Is it always the same consonents that return with 'an'?
    How to attach file: http://www.accessforums.net/showthread.php?t=70301 To provide db: copy, remove confidential data, run compact & repair, zip w/Windows Compression.

  3. #3
    timmygrover is offline Novice
    Windows Vista Access 2003
    Join Date
    Dec 2011
    Posts
    26
    I used the shortened expression and the problem fixed itself! Thanks for the tip! As far as RND(), I've been using it to populate a field with a random integer between a given range, (i.e. randomly select a number between 1-10) and then I have another field with an IIF statement which outputs a few select variables based on the random output of the other column. It seems to be working fine, I just didn't know if they way I'd gone about it was factoring into my other issue.

    Thanks for your help! Not only did you solve my problem, you've armed me with knowledge and made me a better access-y dude!

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

Similar Threads

  1. Proper Case or Capitalization help
    By tshirttom in forum Programming
    Replies: 5
    Last Post: 03-23-2012, 10:37 AM
  2. Replies: 37
    Last Post: 01-11-2012, 02:16 AM
  3. Help with proper where portion
    By tmcrouse in forum Queries
    Replies: 1
    Last Post: 10-11-2011, 03:25 PM
  4. Proper Error Trapping
    By SemiAuto40 in forum Programming
    Replies: 6
    Last Post: 08-11-2011, 10:22 AM
  5. Proper way to store Names
    By trb5016 in forum Database Design
    Replies: 5
    Last Post: 08-22-2010, 10:16 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