Results 1 to 5 of 5
  1. #1
    KathyCo is offline Novice
    Windows 10 Access 2010 64bit
    Join Date
    Nov 2016
    Location
    North Carolina
    Posts
    8

    Question Delete Leading Zeros

    I have a query where I need to delete the first four digits and the leading zeros after that. The code is below and I am using the right function to get rid of the first four digits. The issue is the result set could have no 0s, one 0 or 2 0s. How do I eliminate the zeros. I need to do this so I can match it to another number (original journal entry). Here is an example of the possible numbers:

    0612001519
    0702021566
    0712123802


    SELECT dbo_gl_history.a_org, dbo_gl_history.a_object, dbo_gl_history.a_project, dbo_gl_history.j_jnl_source, dbo_gl_history.h_effective_date, dbo_gl_history.h_gross_amount, dbo_gl_history.h_ref4_jnl_descsh, Right([h_ref4_jnl_descsh],6) AS Expr1
    FROM dbo_gl_history


    WHERE (((dbo_gl_history.a_org) Like "3*") AND ((dbo_gl_history.a_object) Like "7*") AND ((dbo_gl_history.a_project)>"0") AND ((dbo_gl_history.j_jnl_source)="GRV"));

  2. #2
    pbaldy's Avatar
    pbaldy is offline Who is John Galt?
    Windows XP Access 2007
    Join Date
    Feb 2010
    Location
    Nevada, USA
    Posts
    22,643
    Try wrapping that in the Val() or CLng() functions.
    Paul (wino moderator)
    MS Access MVP 2007-2019
    www.BaldyWeb.com

  3. #3
    ranman256's Avatar
    ranman256 is offline VIP
    Windows Vista Access 2010 32bit
    Join Date
    Apr 2014
    Location
    Kentucky
    Posts
    9,549
    Use a numeric field, not string.

  4. #4
    KathyCo is offline Novice
    Windows 10 Access 2010 64bit
    Join Date
    Nov 2016
    Location
    North Carolina
    Posts
    8
    Val() an dCLng() both solve my issues. Thank you so much!!!

  5. #5
    pbaldy's Avatar
    pbaldy is offline Who is John Galt?
    Windows XP Access 2007
    Join Date
    Feb 2010
    Location
    Nevada, USA
    Posts
    22,643
    Happy to help!
    Paul (wino moderator)
    MS Access MVP 2007-2019
    www.BaldyWeb.com

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

Similar Threads

  1. Do not add leading zeros
    By phifer2088 in forum Access
    Replies: 5
    Last Post: 03-02-2015, 10:05 AM
  2. Trying to get leading zeros to show
    By Pegasus_Angel in forum Access
    Replies: 3
    Last Post: 10-25-2012, 11:40 AM
  3. Leading Zeros
    By dirtbiker1824 in forum Access
    Replies: 1
    Last Post: 03-14-2011, 02:16 PM
  4. Adding Leading Zeros
    By jo15765 in forum Access
    Replies: 13
    Last Post: 11-20-2010, 11:11 PM
  5. leading 'Zeros' in data
    By wasim_sono in forum Forms
    Replies: 3
    Last Post: 04-06-2009, 11:57 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