Results 1 to 5 of 5
  1. #1
    Brian88195 is offline Novice
    Windows 7 64bit Access 2010 64bit
    Join Date
    Jul 2015
    Posts
    2

    Textbox input will auto complete another text box

    Hi, i am a new user to access with background training in Access. I have searched for this answer, however i have been unable to find an answer that works for me. The question i have is, that i would like to type a Policy Number in one text box and the first character of the Policy Number indicates the company that it is associated with. I would like the associated company to be automatically generated in the following text box. I created a table that contains all of the companies and the first character of the policy will always be a letter that represents a specific company.



    Example:

    Policy number: x12345
    x= Company ABC

    Would like ABC to automatically generate in the text box labeled Company.

    Please let me know if additional info or screen shots will be of any value to help solve this question.

    Thanks

  2. #2
    CJ_London is online now VIP
    Windows 8 Access 2010 32bit
    Join Date
    Mar 2015
    Posts
    11,430
    in your policy number afterupdate event put something like this code

    Companytxtbox=dlookup("companyname","tblcompanies" ,"CompanyID='" & left(policynumber,1) & "'")

    change all names to match what you have as your control, field and table names. If you have spaces (which is not a good thing) then you will need to surround names with square brackets

  3. #3
    Brian88195 is offline Novice
    Windows 7 64bit Access 2010 64bit
    Join Date
    Jul 2015
    Posts
    2
    Thank you, Ajax.

    this is the code that I came up with after changing my control, field and table names:

    Text229=dlookup("CompanyAbreviation","tblCompanies " ,"CompanyName='" & left(Text182,1) & "'")

    When I put this in the afterupdate event for the control where the Policy Number will be typed in it doesn't work for me.

    The policy number is typed in a textbox (named Text182), I would like the company name to be generated in the following textbox (named Text229). the table where the companies are stored is named "tblCompanies", the abbreviation for the company is stored in a column labeled "CompanyAbreviation", the company name, which I would like to have populated in textbox "Text229" is stored in a column labeled "CompanyName"

    I have a relationship setup between tblCompanies and tblNewTransaction for the companies.

    Thanks for your help and let me know if I can provide you with additional information to help.

    Thanks,
    Brian

  4. #4
    CJ_London is online now VIP
    Windows 8 Access 2010 32bit
    Join Date
    Mar 2015
    Posts
    11,430
    It looks to me tlike the way you have set you dlookup is to find a companyabbreviation for a company with is a single character - shouldn't these be the other way round? i.e.

    Text229=dlookup("CompanyName","tblCompanies " ,"CompanyAbbreviation='" & left(Text182,1) & "'")

  5. #5
    June7's Avatar
    June7 is offline VIP
    Windows 7 64bit Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    52,929
    The letter prefix is first letter of company name? So you can represent only 26 companies? You don't have more than one company name beginning with same letter?

    Text229 = DLookup("CompanyAbreviation", "tblCompanies ", "Left(CompanyName, 1) ='" & Left(Text182, 1) & "'")

    or

    Text229 = DLookup("CompanyAbreviation", "tblCompanies ", "CompanyName Like '" & Left(Text182, 1) & "*'")

    NOTE: abbreviation actually has two b's
    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. auto complete fields
    By mona in forum Access
    Replies: 3
    Last Post: 05-09-2012, 07:41 AM
  2. Replies: 3
    Last Post: 11-04-2011, 01:50 PM
  3. Replies: 3
    Last Post: 09-20-2011, 11:54 AM
  4. Replies: 15
    Last Post: 04-01-2011, 11:41 AM
  5. Auto Complete Data
    By manicamaniac in forum Access
    Replies: 5
    Last Post: 09-14-2010, 03:38 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