Results 1 to 6 of 6
  1. #1
    Poohbear0471 is offline Advanced Beginner
    Windows 7 32bit Access 2010 32bit
    Join Date
    Oct 2012
    Posts
    78

    MID function

    I tried searching the forums for help with my MID function problem, but it's too short of a search term to get any results. I have field CntlNum, which is a 17 character alphanumeric field. I need to populate field AccntNum with the first 10 digits of CntlNum.



    In the AccntNum field on my form, I set the default value to =MID(CntlNum, 1, 10), but it's not working. Suggestions?

  2. #2
    Micron is online now Virtually Inert Person
    Windows 10 Access 2016
    Join Date
    Jun 2014
    Location
    Ontario, Canada
    Posts
    12,737
    Your expression looks OK, so maybe post some sample data and the expected result. The first 10 characters and the first 10 digits of a 17 character string are not necessarily the same thing.
    The more we hear silence, the more we begin to think about our value in this universe.
    Paraphrase of Professor Brian Cox.

  3. #3
    pbaldy's Avatar
    pbaldy is offline Who is John Galt?
    Windows XP Access 2007
    Join Date
    Feb 2010
    Location
    Nevada, USA
    Posts
    22,518
    I probably wouldn't save a field that can be so easily calculated from another, or it may be a candidate for the calculated field data type. In your case, the default is applied before you've populated the CntlNum field. If you wanted to do this, I'd use the after update event of the textbox containing CntlNum and populate the AccntNum textbox.
    Paul (wino moderator)
    MS Access MVP 2007-2019
    www.BaldyWeb.com

  4. #4
    Poohbear0471 is offline Advanced Beginner
    Windows 7 32bit Access 2010 32bit
    Join Date
    Oct 2012
    Posts
    78
    @Micron, A sample of the CntlNum would be 1234567890AB00012. It's always 10 digits, two letters, five digits. I need the AccntNum field to populate the initial 10 digits, 1234567890. The data type on both fields is text.
    @PBaldy, I don't have the option to not save the AccntNum field as it's our primary customer identifier and is needed for federal reporting. I'll try moving it to the CntlNum afterupdate.
    Thanks!

  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,518
    I'd consider the Calculated data type, though I haven't used it myself. An expression of

    Left([CntlNum],10)

    should work, and no code required.
    Paul (wino moderator)
    MS Access MVP 2007-2019
    www.BaldyWeb.com

  6. #6
    Micron is online now Virtually Inert Person
    Windows 10 Access 2016
    Join Date
    Jun 2014
    Location
    Ontario, Canada
    Posts
    12,737
    answer removed

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

Similar Threads

  1. Replies: 15
    Last Post: 10-17-2018, 09:26 PM
  2. Replies: 15
    Last Post: 05-31-2017, 02:10 PM
  3. Replies: 2
    Last Post: 02-26-2017, 11:31 AM
  4. Replies: 8
    Last Post: 11-04-2014, 10:44 PM
  5. Replies: 8
    Last Post: 01-31-2014, 01:45 PM

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