+ Reply to Thread
Results 1 to 10 of 10

Delete characters and add * in front and last characters in ACCESS QUERY

  1. #1
    Registered User
    Join Date
    05-25-2012
    Location
    Virginia beach, Virginia
    MS-Off Ver
    Excel 2007
    Posts
    57

    Delete characters and add * in front and last characters in ACCESS QUERY

    BEFORE AFTER
    PO00699873 *699873*
    PO00700521 *700521*
    PO00698336 *698336*

    I have a column called Vendor PO Number in my access query and I would like to be able to delete the first four characters and then add a wild card symbol * in front and the last characters (see above examples)

    I figure out how to delete the first four digits by building an expression
    Vendor PO: Mid([Vendor PO Number],5)

    BUT

    I have not figure (or if possible) to add * in front and behind the last characters. Finish product should look like *699873* from the original format of PO006998723.


    I would appreicate anyone help.

  2. #2
    Forum Moderator alansidman's Avatar
    Join Date
    02-02-2010
    Location
    Steamboat Springs, CO
    MS-Off Ver
    MS Office 365 Version 2404 Win 11 Home 64 Bit
    Posts
    23,865

    Re: Delete characters and add * in front and last characters in ACCESS QUERY

    Try an update query. Your expression would be "*" & Mid([Vendor PO Number],5) & "*"

    Look at this video on manipulating data with a query

    http://www.datapigtechnologies.com/f...anipulate.html
    Alan עַם יִשְׂרָאֵל חַי


    Change an Ugly Report with Power Query
    Database Normalization
    Complete Guide to Power Query
    Man's Mind Stretched to New Dimensions Never Returns to Its Original Form

  3. #3
    Registered User
    Join Date
    05-25-2012
    Location
    Virginia beach, Virginia
    MS-Off Ver
    Excel 2007
    Posts
    57

    Re: Delete characters and add * in front and last characters in ACCESS QUERY

    Thank you so much, you saved some of my brain cells

  4. #4
    Registered User
    Join Date
    05-25-2012
    Location
    Virginia beach, Virginia
    MS-Off Ver
    Excel 2007
    Posts
    57

    Re: Delete characters and add * in front and last characters in ACCESS QUERY

    alansidman,

    Question, I have rows which does not have any chararacter and i would like to show nothing (blank) in these rows instead of **, (I would still use this expression "*" & Mid([Vendor PO Number],5) & "*" for row which as characters.

    Thanks again

    row 1 *699873*
    row 2 ** ( I would like blank and not **)
    row 3 *698336*
    row 4 ** ( I would like blank and not **)

  5. #5
    Forum Moderator alansidman's Avatar
    Join Date
    02-02-2010
    Location
    Steamboat Springs, CO
    MS-Off Ver
    MS Office 365 Version 2404 Win 11 Home 64 Bit
    Posts
    23,865

    Re: Delete characters and add * in front and last characters in ACCESS QUERY

    I am guessing you will need to run a second update query after the first one that places a null in the fields holding the values **.

    I never asked but did you want to update the table or did you just wish that the PO be displayed in a query with the asterisks. I had assumed you wished to update the table and that may not have been your wishes.

    Alan
    Last edited by alansidman; 02-01-2013 at 01:00 PM.

  6. #6
    Forum Guru Norie's Avatar
    Join Date
    02-02-2005
    Location
    Stirling, Scotland
    MS-Off Ver
    Microsoft Office 365
    Posts
    19,643

    Re: Delete characters and add * in front and last characters in ACCESS QUERY

    Try this for the expression.

    Iif(IsNull([Vendor PO Number]), "", "*" & Mid([Vendor PO Number],5) & "*")

    By the way, just curious really but why are you doing this?
    If posting code please use code tags, see here.

  7. #7
    Registered User
    Join Date
    05-25-2012
    Location
    Virginia beach, Virginia
    MS-Off Ver
    Excel 2007
    Posts
    57

    Re: Delete characters and add * in front and last characters in ACCESS QUERY

    Norie, I have a database which everyone will just copy and paste this string (*699873*) into another program and the data will be retrieve. The expression is also entering ** in the rows which has no data, but my group is getting confused with the ** in the cell.

  8. #8
    Forum Guru Norie's Avatar
    Join Date
    02-02-2005
    Location
    Stirling, Scotland
    MS-Off Ver
    Microsoft Office 365
    Posts
    19,643

    Re: Delete characters and add * in front and last characters in ACCESS QUERY

    Did you try the expression I posted?

  9. #9
    Registered User
    Join Date
    05-25-2012
    Location
    Virginia beach, Virginia
    MS-Off Ver
    Excel 2007
    Posts
    57

    Re: Delete characters and add * in front and last characters in ACCESS QUERY

    Alan,

    This work perfectly, my database is updated daily from Oracle report and this expression helps by automatically delete the first four digits and add wild card before/after the numbers. thanks again

  10. #10
    Registered User
    Join Date
    05-25-2012
    Location
    Virginia beach, Virginia
    MS-Off Ver
    Excel 2007
    Posts
    57

    Re: Delete characters and add * in front and last characters in ACCESS QUERY

    Yes and work great and this will make my group happy. Thank you for your help and have a great day.

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Bookmarks

Posting Permissions

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

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1