Page 1 of 2 12 LastLast
Results 1 to 15 of 21
  1. #1
    Rhubie is offline Advanced Beginner
    Windows 7 64bit Access 2010 64bit
    Join Date
    Aug 2012
    Posts
    85

    Unhappy 4th character of a field

    DUXPrice: IIf (Left([WBCode],4)="X"),([WBCost]*2)*(9/10),Null))

    I want to check the 4th character of the WBCode - not sure what I am doing wrong?

  2. #2
    Bob Fitz's Avatar
    Bob Fitz is offline Access Developer
    Windows XP Access 2003
    Join Date
    May 2011
    Location
    Essex UK
    Posts
    3,610
    Try the Mid(string, start[, length]) function

    DUXPrice: IIf (Mid([WBCode],4,1)="X"),([WBCost]*2)*(9/10),Null))
    If this helped, please click the star at the bottom left of this posting and add to my reputation . Many thanks.
    Bob Fitzpatrick

  3. #3
    orange's Avatar
    orange is offline Moderator
    Windows XP Access 2003
    Join Date
    Sep 2009
    Location
    Ottawa, Ontario, Canada; West Palm Beach FL
    Posts
    16,848

  4. #4
    Rhubie is offline Advanced Beginner
    Windows 7 64bit Access 2010 64bit
    Join Date
    Aug 2012
    Posts
    85
    DUXPrice: IIf (Mid([WBCode],4,1)="X"),([WBCost]*2)*(9/10),Null))

    function containing wrong number of arguments error

  5. #5
    orange's Avatar
    orange is offline Moderator
    Windows XP Access 2003
    Join Date
    Sep 2009
    Location
    Ottawa, Ontario, Canada; West Palm Beach FL
    Posts
    16,848

  6. #6
    Rhubie is offline Advanced Beginner
    Windows 7 64bit Access 2010 64bit
    Join Date
    Aug 2012
    Posts
    85
    DUXPrice: IIf(Left([WBCode],4="X"),([WBCost]*2)*(9/10),0)

    This is not giving me an error when I save it - but my value is #ERROR

  7. #7
    Rhubie is offline Advanced Beginner
    Windows 7 64bit Access 2010 64bit
    Join Date
    Aug 2012
    Posts
    85
    wrong number of arguments didn't work

  8. #8
    orange's Avatar
    orange is offline Moderator
    Windows XP Access 2003
    Join Date
    Sep 2009
    Location
    Ottawa, Ontario, Canada; West Palm Beach FL
    Posts
    16,848
    Where do you get WBCode from? How is it defined? Do you have missing values in your data source?
    Have you tried a sample query to just output WBCode to see what values exist?

    Tell us more about your situation.

    And bookmark the page I mentioned earlier.


    DUXPrice: IIf(Left([WBCode],4)="X",([WBCost]*2)*(9/10),0)

  9. #9
    Bob Fitz's Avatar
    Bob Fitz is offline Access Developer
    Windows XP Access 2003
    Join Date
    May 2011
    Location
    Essex UK
    Posts
    3,610
    Try:
    DUXPrice: IIf(Mid([WBCode],4,1)="X",([WBCost]*2)*(9/10),Null)
    If this helped, please click the star at the bottom left of this posting and add to my reputation . Many thanks.
    Bob Fitzpatrick

  10. #10
    Rhubie is offline Advanced Beginner
    Windows 7 64bit Access 2010 64bit
    Join Date
    Aug 2012
    Posts
    85
    The field wbcode is an entered field - a mandatory field (required - never an empty field)

    the rest is calculation - a sample code would be 06-X0011

    I have the query expression field as a number with 2 decimals

    DUXPrice: IIf(Left([WBCode],4="X"),([WBCost]*2)*(9/10),0)

    The fourth position from the left should only find the X - if some of the values in the field are only 2 characters (NA) would that cause the problem? I will try to make sure all codes have at least 4 characters and try.

    This does not give me an error when I save it - but it does give me a #ERROR for the value

  11. #11
    Rhubie is offline Advanced Beginner
    Windows 7 64bit Access 2010 64bit
    Join Date
    Aug 2012
    Posts
    85
    Checked all of the codes they all have 4 characters or more.

    I'm really stuck on this one - doesn't make sense

  12. #12
    orange's Avatar
    orange is offline Moderator
    Windows XP Access 2003
    Join Date
    Sep 2009
    Location
    Ottawa, Ontario, Canada; West Palm Beach FL
    Posts
    16,848
    Did you try the code in my post #8? I haven't executed it, but I think it matches your requirement.

  13. #13
    Bob Fitz's Avatar
    Bob Fitz is offline Access Developer
    Windows XP Access 2003
    Join Date
    May 2011
    Location
    Essex UK
    Posts
    3,610
    Quote Originally Posted by Rhubie View Post
    Checked all of the codes they all have 4 characters or more.

    I'm really stuck on this one - doesn't make sense
    Did you try:
    DUXPrice: IIf(Mid([WBCode],4,1)="X",([WBCost]*2)*(9/10),Null)
    As in post #9
    If this helped, please click the star at the bottom left of this posting and add to my reputation . Many thanks.
    Bob Fitzpatrick

  14. #14
    Rhubie is offline Advanced Beginner
    Windows 7 64bit Access 2010 64bit
    Join Date
    Aug 2012
    Posts
    85
    this one

    DUXPrice: IIf(Left([WBCode],4)="X",([WBCost]*2)*(9/10),0)

    I get all 0's - there should be 12 of my rows that should have a value

    Ex 06-X0011 (I have 12 rows that an X for the 4th character value

  15. #15
    Rhubie is offline Advanced Beginner
    Windows 7 64bit Access 2010 64bit
    Join Date
    Aug 2012
    Posts
    85
    I added an expression

    Left([WBCode],4)

    if gives me the first 4 characters - not just the 4th character - how can I strip the first 3?

Page 1 of 2 12 LastLast
Please reply to this thread with any new information or opinions.

Similar Threads

  1. Character limit in form field
    By tanveerksingh in forum Forms
    Replies: 3
    Last Post: 08-22-2012, 11:04 AM
  2. Prefix character in ID field
    By Zbeibu in forum Access
    Replies: 2
    Last Post: 05-14-2012, 07:21 AM
  3. Replies: 6
    Last Post: 10-28-2011, 11:15 AM
  4. Fixed character length of field
    By tylerg11 in forum Access
    Replies: 3
    Last Post: 09-29-2011, 11:58 AM
  5. Character Limits
    By nashr1928 in forum Reports
    Replies: 5
    Last Post: 12-08-2010, 01:29 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