Results 1 to 8 of 8
  1. #1
    angie is offline Competent Performer
    Windows 8 Access 2013
    Join Date
    Dec 2013
    Posts
    232

    Add P in front of a numberr

    Hi I have a field called " workordersID" and a check box named "Pollock's" I would like to do the following.

    If the check box Pollock's is checked (yes) than I would like workordersID to add a "P" in front of the workordersID number.



    The workorderID is a auto number. Can this be done?

    Thanks Angie

  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
    IIf([Pollock's] = True, "P", "") & workordersID

    You don't really have the inadvisable apostrophe in the field name, do you?
    Paul (wino moderator)
    MS Access MVP 2007-2019
    www.BaldyWeb.com

  3. #3
    angie is offline Competent Performer
    Windows 8 Access 2013
    Join Date
    Dec 2013
    Posts
    232
    Which field do I put this in the workordersID or the Pollock's?
    And do I add it as default value ?
    Thanks
    Angie

  4. #4
    pbaldy's Avatar
    pbaldy is offline Who is John Galt?
    Windows XP Access 2007
    Join Date
    Feb 2010
    Location
    Nevada, USA
    Posts
    22,652
    I would probably just use that for display, not store it.
    Paul (wino moderator)
    MS Access MVP 2007-2019
    www.BaldyWeb.com

  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
    You have to understand that this cannot be done in the Textbox that is bound to your workordersID Field; Autonumber Fields cannot be edited, period. So you'll need to have another Control on any Forms/Reports that you want this to appear on. And as Paul suggested, because this can be a calculated value, it should not be bound to a Field in the underlying Table, but simply recalculated as needed. So place an Equal Sign in front of his code

    =IIf([Pollock's] = True, "P", "") & [workordersID]

    and place it in the Control Source Property of an Unbound Textbox.

    BTW, his concern with having that apostrophe in Pollack’s is dead on; sooner or later it will bite you in places you don’t want to be bitten in, and will cause you extra work, even before that!

    Also, having said all of this, you also need to understand that the Autonumber Datatype is intended to be used for one purpose and only one purpose, to provide a unique identifier for each Record. Here's a post I've archived from a gentleman named John Vinson, MVP, explaining how Autonumbers work:

    When using Autonumber, do be aware that there will be gaps in the numbering any record that's deleted will leave a gap; hitting <Esc> after starting a record will leave a gap; adding records using an Append query may leave a gap, often a huge one; replicating the database will make your invoice numbers random.

    In short... it's best NOT to use Autonumbers for human consumption, and particularly not for consumption by accountants and auditors. Invoice sequences like 319, 321, 322, 385, 386, 221841246, 1083225152 make such people get very nervous.

    If the possible problems John has pointed out won't present a problem for you, then go ahead and use the Autonumber.

    Linq ;0)>

  6. #6
    June7's Avatar
    June7 is offline VIP
    Windows 7 64bit Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    53,771
    To echo those comments, avoid spaces and special characters/punctuation (underscore is exception) in naming convention. Also avoid reserved words as names.
    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.

  7. #7
    ItsMe's Avatar
    ItsMe is offline Sometimes Helpful
    Windows 7 64bit Access 2010 32bit
    Join Date
    Aug 2013
    Posts
    7,862
    You can format a field at the table layer. I believe the syntax is.
    >" P"

  8. #8
    angie is offline Competent Performer
    Windows 8 Access 2013
    Join Date
    Dec 2013
    Posts
    232
    Thanks everyone it works. You are great. Have a great day. Angie

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

Similar Threads

  1. Front end help
    By hrenee in forum Reports
    Replies: 6
    Last Post: 10-21-2013, 11:28 AM
  2. Front end changes
    By Guitarzan in forum Access
    Replies: 3
    Last Post: 08-06-2012, 06:39 AM
  3. update front end mde
    By slimjen in forum Access
    Replies: 2
    Last Post: 10-31-2011, 11:37 AM
  4. Where to save front-end
    By AndrewAfresh in forum Access
    Replies: 12
    Last Post: 07-05-2011, 11:27 AM
  5. Front-End Ballooning
    By jgelpi16 in forum Access
    Replies: 4
    Last Post: 12-21-2010, 10:44 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