Results 1 to 10 of 10
  1. #1
    medusa3604 is offline Novice
    Windows 7 64bit Access 2013
    Join Date
    Dec 2014
    Posts
    9

    Mid Function


    Hi,

    I have imported data from another database where the dates are in the wrong format.

    Itīs yyyymmdd and I want yyyy-mm-dd.

    My plan was to use Left +"-" + Mid +"-" + Right

    Left and right works fine but Mid does not. Can someone help me with this, Im going crazy.

    This is how I write the Mid function Mid( [GILTIGFRAN] , 5, 2)

    And I get this back

    Click image for larger version. 

Name:	Mid.jpg 
Views:	21 
Size:	18.0 KB 
ID:	19039

    What am I doing wrong?

    / Anders
    Sweden

  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,652
    For starters, try & instead of + to concatenate. Also make sure the field doesn't have any Nulls.
    Paul (wino moderator)
    MS Access MVP 2007-2019
    www.BaldyWeb.com

  3. #3
    medusa3604 is offline Novice
    Windows 7 64bit Access 2013
    Join Date
    Dec 2014
    Posts
    9
    Thanks for your answer.

    Right now Im just trying to get this function to work so I not using + or & but thanks for the tip.

    Can it be some setting somewhere because now I try another formula on another field.

    IIf( [KVARVARANDE DJUR] =0, "G", "IG") and I get the same message.

    I should say that I put these formulas in calculated fields, can that be some reason?

    / Anders
    Sweden

  4. #4
    June7's Avatar
    June7 is offline VIP
    Windows 7 64bit Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    53,770
    I tested the Mid and IIf functions in table Calculated type field and they work. Post the complete exact expression.

    If you want to provide db for analysis, follow instructions at bottom of my post.
    How to attach file: http://www.accessforums.net/showthread.php?t=70301 To provide db: copy, remove confidential data, run compact & repair, zip w/Windows Compression.

  5. #5
    Missinglinq's Avatar
    Missinglinq is offline VIP
    Windows 7 64bit Access 2007
    Join Date
    May 2012
    Location
    Richmond (Virginia, not North Yorkshire!)
    Posts
    3,018
    Quote Originally Posted by June7 View Post

    ...Post the complete exact expression...

    ...follow instructions at bottom of my post...
    Both excellent suggestions! Having problems with two different standard VBA Functions means you're either

    • Trying to assign the results incorrectly
    • Are missing a Reference Library that the Functions reside in


    Seeing exactly what you're doing will help us figure out which.

    Linq ;0)>

  6. #6
    medusa3604 is offline Novice
    Windows 7 64bit Access 2013
    Join Date
    Dec 2014
    Posts
    9
    Hi,

    In this picture you see the left function working properly:
    Click image for larger version. 

Name:	LEFT Function working.jpg 
Views:	14 
Size:	77.7 KB 
ID:	19042

    Then I create a new calculated field that is not working, see picture.
    Click image for larger version. 

Name:	MID function not working.jpg 
Views:	15 
Size:	70.4 KB 
ID:	19043

    Thanks for your help.

    / Anders
    Sweden

  7. #7
    pbaldy's Avatar
    pbaldy is offline Who is John Galt?
    Windows XP Access 2007
    Join Date
    Feb 2010
    Location
    Nevada, USA
    Posts
    22,652
    Looks like the wrong pic, but try taking the spaces out. Shouldn't matter, but worth trying.
    Paul (wino moderator)
    MS Access MVP 2007-2019
    www.BaldyWeb.com

  8. #8
    June7's Avatar
    June7 is offline VIP
    Windows 7 64bit Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    53,770
    Maybe something changed with 2013 because it works for me in 2010. Access drops the unnecessary spaces.

    Instead of Calculated type field in table, try the expression in a query.
    How to attach file: http://www.accessforums.net/showthread.php?t=70301 To provide db: copy, remove confidential data, run compact & repair, zip w/Windows Compression.

  9. #9
    medusa3604 is offline Novice
    Windows 7 64bit Access 2013
    Join Date
    Dec 2014
    Posts
    9
    Hi,

    Thanks, the pictures are correct.

    Ok, I will try it in a query.

    / Anders
    Sweden

  10. #10
    pbaldy's Avatar
    pbaldy is offline Who is John Galt?
    Windows XP Access 2007
    Join Date
    Feb 2010
    Location
    Nevada, USA
    Posts
    22,652
    Quote Originally Posted by medusa3604 View Post
    Hi,

    Thanks, the pictures are correct.
    both pics of query results show the successful Left() function.
    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. Replies: 8
    Last Post: 11-04-2014, 10:44 PM
  2. Replies: 8
    Last Post: 01-31-2014, 01:45 PM
  3. Function
    By Alex Motilal in forum Programming
    Replies: 6
    Last Post: 06-05-2013, 08:33 PM
  4. Between function
    By brownk in forum Queries
    Replies: 2
    Last Post: 09-10-2012, 08:33 AM
  5. Want function to get current function name
    By Davis DeBard in forum Programming
    Replies: 2
    Last Post: 08-13-2009, 05:02 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