Results 1 to 2 of 2
  1. #1
    Anthony123 is offline Novice
    Windows XP Access 2007
    Join Date
    Jan 2013
    Posts
    1

    Exclamation Auto populate text box with string from Combobox

    Hello, I have searched all over and tried Many many things but cant seem to get a solution.

    I have a form with a combobox (from a table, the field name is Agency). The combobox options are: TMS, HRD, and TYM.

    I also have a textbox (from a table, the field name is Case_Code) *THIS IS ALSO A PRIMARY KEY*

    When a user selects a Agency from the combobox (lets say 'HRD'), i need the text box to automatically populate with 'HRD-2013-001'. If on the next record, they chose 'TMS' the combobox would say 'TMS-2013-002' and so forth, will the last part of the srting always increasing by 1.



    I have tried editing the contol source of the textbox but i end up getting a "Index or Primary Key cannot be Null" Error

    Note: This is a simple way of putting it, eventually i will need to be able to start over with the numbers based on the Agency selected. Example: if the user chooses 'TYM', the textbox would say "TYM-2013-001', they save that record and the next time they choose 'HRD' the text box would say 'HRD-2013-001', if they chose 'TYM' for the next record it would be '....002, 003, 004' and so forth. Same for anyother Agancy selected.

    If you can help with this example that would be great! Otherwise a simple solution to the first example will get me a long way! Thanks in advance!!

  2. #2
    June7's Avatar
    June7 is online now VIP
    Windows XP Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    52,929
    Custom unique identifier is a common topic in forum. A search should return many threads.

    Review:
    https://www.accessforums.net/access/...ers-21361.html
    https://www.accessforums.net/access/...lue-28208.html
    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.

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

Similar Threads

  1. Replies: 1
    Last Post: 08-22-2012, 01:24 PM
  2. Replies: 2
    Last Post: 08-22-2012, 07:59 AM
  3. How to populate combobox via VBA
    By chuki2 in forum Programming
    Replies: 7
    Last Post: 08-15-2012, 10:42 AM
  4. Populate a text box based on a combobox selection?
    By Richie27 in forum Programming
    Replies: 4
    Last Post: 04-25-2012, 08:00 AM
  5. Replies: 5
    Last Post: 03-07-2012, 12:57 PM

Tags for this Thread

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