Results 1 to 4 of 4
  1. #1
    Mnelson is offline Novice
    Windows 7 64bit Access 2010 64bit
    Join Date
    Jun 2012
    Posts
    7

    Angry Update query


    Hello I have an excel spread sheet with a column called Acct_ID. Heres what I'm trying to do.

    I have a column with account numbers in this form:

    R12345
    M23456
    T12345

    I'm trying to convert the first letter to a sequence of numbers then keep the remaining numbers. For example


    R12345 to 10012345
    M23456 to 20023456
    T12345 to 30012345

    I've created the following code to do so. But there's syntax errors and I'm unsure of what is wrong in my update query.

    iif(left(ac,1)="R";"100"&right(ac,5);iif(left(ac,1 )="M";"200"&right(ac,5);iif(left(ac,1)="T";"300"&r ight(ac,5)))

    Any ideas?

  2. #2
    Mnelson is offline Novice
    Windows 7 64bit Access 2010 64bit
    Join Date
    Jun 2012
    Posts
    7
    By the way the error I get is this:

    The expression you entered contains invalid syntax.
    You omitted an operand or operator, you entered an invalid character or comma, or you entered text without surrounding it in quotation marks

  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,722
    This is an Access forum - is your question Excel or Access related?
    Please provide more info if it Access/vba related.


    Table layout, field names etc.
    Show the sql for your update query.

  4. #4
    ssanfu is offline Master of Nothing
    Windows XP Access 2000
    Join Date
    Sep 2010
    Location
    Anchorage, Alaska, USA
    Posts
    9,664
    There is a missing closing parenthesis and the semi-colons should be commas. The last FALSE clause is also missing. Here are two ways of writing the formula:

    Code:
      IIf(Left(ac, 1) = "R", "100" & Right(ac, 5), IIf(Left(ac, 1) = "M", "200" & Right(ac, 5), IIf(Left(ac, 1) = "T", "300" & Right(ac, 5), "INVALID PREFIX- Not R, M or T")))
    
    or
    
      IIf(Left(ac, 1) = "R", "100", IIf(Left(ac, 1) = "M", "200", IIf(Left(ac, 1) = "T", "300", "INVALID PRFIX- "))) & Right(ac, 5)

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

Similar Threads

  1. Replies: 4
    Last Post: 11-10-2011, 03:41 PM
  2. Replies: 2
    Last Post: 09-21-2011, 01:30 PM
  3. Replies: 1
    Last Post: 08-19-2011, 12:16 PM
  4. Update 2 tables with one Update Query
    By Douglasrac in forum Queries
    Replies: 4
    Last Post: 04-14-2011, 08:33 AM
  5. Update Query- selective update?
    By stephenaa5 in forum Queries
    Replies: 1
    Last Post: 10-29-2009, 11:15 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