Results 1 to 4 of 4
  1. #1
    Gold Lounger
    Join Date
    Feb 2004
    Location
    Cape Town, RSA
    Posts
    3,444
    Thanks
    0
    Thanked 1 Time in 1 Post

    Help with a formula to update data. (Access XP)

    I have a table of codes like this: D10-123, PE09-125, J04-184, B08-139, J11-194...etc
    I have created an update query of a test table where I want the query to update the strings starting with J to read CT04-084 and CT11-094. IE: It must change the J to a CT and the 1 (after the hyphen) to a 0.
    As you can see, the table name is Table1 and the field name is Test. This is a dummy table to attempt it. The formula below has a syntax error that I cannot fix. Please help. Tx
    = IIf ( Left ( <table1>![Test] , 1)="J" ,AND(Left ( <table1>![Test] , 1)="CT",Mid(<table1>![Test] , 5,1)="0") , <table1>![Test] )
    Regards,
    Rudi

  2. #2
    Plutonium Lounger
    Join Date
    Mar 2002
    Posts
    84,353
    Thanks
    0
    Thanked 29 Times in 29 Posts

    Re: Help with a formula to update data. (Access XP)

    Add criteria <code>Like "J*"</code> to the Test field.
    Set the Update to line to <code>Replace(Replace([Test],"J","CT"),"-1","-0")</code>

  3. #3
    Gold Lounger
    Join Date
    Feb 2004
    Location
    Cape Town, RSA
    Posts
    3,444
    Thanks
    0
    Thanked 1 Time in 1 Post

    Re: Help with a formula to update data. (Access XP)

    Ha...worked like magic. Tx Hans. You make it seem so simple...as always.

    Is Replace nested into another Replace here?
    Regards,
    Rudi

  4. #4
    Plutonium Lounger
    Join Date
    Mar 2002
    Posts
    84,353
    Thanks
    0
    Thanked 29 Times in 29 Posts

    Re: Help with a formula to update data. (Access XP)

    > Is Replace nested into another Replace here?

    What else do you think it could be? Is this a trick question?

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •