Page 1 of 2 12 LastLast
Results 1 to 15 of 18
  1. #1
    pwalter83 is offline Novice
    Windows XP Access 2007
    Join Date
    Dec 2011
    Posts
    19

    Autopopulate a textbox based on the lookup table


    Hi,

    I have a requirement to autopopulate a textbox (DIVISION_CD) based on the value in another textbox(LINE_CD).

    A table - DIVISION already exists which contains the 2 columns - LINE_CD and DIVISION_CD. How can I use the DIVISION table as a lookup table to autopopulate the values in the DIVISION_CD textbox based on the matching value in the LINE_CD textbox.

    Would somebody know on how to about this ? I have googled regarding this but have not been able to find any solution. Any suggestions would be appreciated.

    Thanks,
    Paul

  2. #2
    alansidman's Avatar
    alansidman is offline VIP
    Windows 7 32bit Access 2007
    Join Date
    Apr 2010
    Location
    Steamboat Springs
    Posts
    2,529
    This should help

    http://www.baldyweb.com/Autofill.htm

    Alan

  3. #3
    pwalter83 is offline Novice
    Windows XP Access 2007
    Join Date
    Dec 2011
    Posts
    19
    Quote Originally Posted by alansidman View Post
    Thanks for the link but this is not what I am looking for.

    What I need is that the textbox should autopopulate based on the value in the previous textbox and for that it should consult a lookup table(which already exists) for the matching value.

  4. #4
    orange's Avatar
    orange is offline Moderator
    Windows XP Access 2003
    Join Date
    Sep 2009
    Location
    Ottawa, Ontario, Canada; West Palm Beach FL
    Posts
    16,726
    Please show the table structures and some sample data.

  5. #5
    pwalter83 is offline Novice
    Windows XP Access 2007
    Join Date
    Dec 2011
    Posts
    19
    Quote Originally Posted by orange View Post
    Please show the table structures and some sample data.
    Please find the table structure of the DIVISION table below:
    ----------------------------------------------
    CREATE TABLE [dbo].[DIVISION](
    [LINE_CD] [varchar](2)NULL,
    [DIVISION_CD] [varchar](4)NULL
    )
    ON [PRIMARY]
    ----------------------------------------------
    The sample data for the above table:

    ----------------------------------
    INSERT INTO DIVISION
    VALUES('01', 'A432')
    INSERT INTO DIVISION
    VALUES('02', 'A442')
    INSERT INTO DIVISION
    VALUES('03', 'A452')
    INSERT INTO DIVISION
    VALUES('04', 'A462')
    INSERT INTO DIVISION
    VALUES('05', 'A472')
    ----------------------------------

    The textbox - DIVISION_CD needs to be populated with the value based on the matching value of the LINE_CD textbox using the above table as a lookup table for looking up the values of DIVISION_CD column.

    I hope I am able to explain my situation.

    Thanks !

  6. #6
    orange's Avatar
    orange is offline Moderator
    Windows XP Access 2003
    Join Date
    Sep 2009
    Location
    Ottawa, Ontario, Canada; West Palm Beach FL
    Posts
    16,726
    Ok I see the Table, but what is the form where these text boxes are located?
    What are you trying to do--it isn't clear.

  7. #7
    pwalter83 is offline Novice
    Windows XP Access 2007
    Join Date
    Dec 2011
    Posts
    19
    Quote Originally Posted by orange View Post
    Ok I see the Table, but what is the form where these text boxes are located?
    What are you trying to do--it isn't clear.
    Is there some way I can copy paste the form here ? I dont know how to.

    Okay here is the explanation again:

    There are 2 textboxes on the form- LINE_CD and DIVISION_CD. LINE_CD is already auto populated using a combo box. Now, whatever value is displayed in the LINE_CD textbox, based on the values stored in the lookup table(mentioned above), the other textbox- DIVISION_CD needs to be autopopulated. For example, if the LINE_CD value is displayed as '01' then the DIVISION_CD textbox should automatically show up 'A432' (referring to the sample data above).

    I hope it is clear now.

  8. #8
    alansidman's Avatar
    alansidman is offline VIP
    Windows 7 32bit Access 2007
    Join Date
    Apr 2010
    Location
    Steamboat Springs
    Posts
    2,529
    From what you are describing, this seems like what you are trying to do. Look at the attached and if this is not it, them try one more time to explain your needs. Open the form and select in the drop down, and your results are in the second box.

    If this is what you are looking for, then I refer you to the original link -- because this is what I did.

  9. #9
    pwalter83 is offline Novice
    Windows XP Access 2007
    Join Date
    Dec 2011
    Posts
    19
    Quote Originally Posted by alansidman View Post
    From what you are describing, this seems like what you are trying to do. Look at the attached and if this is not it, them try one more time to explain your needs. Open the form and select in the drop down, and your results are in the second box.

    If this is what you are looking for, then I refer you to the original link -- because this is what I did.
    Thanks again !! The problem I am facing is that the LINE_CD column is already autopopulated through a combo box (located above it) and it is not editable by the user and displays only a single value. In other words, I don't have an option to bring in the values for DIVISION_CD in the LINE_CD textbox.

    Please find my form attached. This would make the picture more clear. I should have already done that yesterday and saved you the extra trouble. The form is called- REGISTER_VESSEL.

    Thanks for your help.

  10. #10
    pwalter83 is offline Novice
    Windows XP Access 2007
    Join Date
    Dec 2011
    Posts
    19
    Quote Originally Posted by alansidman View Post
    From what you are describing, this seems like what you are trying to do. Look at the attached and if this is not it, them try one more time to explain your needs. Open the form and select in the drop down, and your results are in the second box.

    If this is what you are looking for, then I refer you to the original link -- because this is what I did.
    Hi Alan,

    I have reached to this point where I enter the DLOOKUP formula in the textbox which goes as :

    =DLookUp("DIVISION_CD","dbo_DIVISION","Text41 = [LINE_CD]")

    But the thing is the value in the DIVISION_CD textbox does not change when the LINE_CD value changes. Could you please give any pointers on this one ?

    Thanks !

  11. #11
    orange's Avatar
    orange is offline Moderator
    Windows XP Access 2003
    Join Date
    Sep 2009
    Location
    Ottawa, Ontario, Canada; West Palm Beach FL
    Posts
    16,726
    Did you look at Alan's example? It seems to do what you're asking. If not, could you please try to explain in more detail.

  12. #12
    alansidman's Avatar
    alansidman is offline VIP
    Windows 7 32bit Access 2007
    Join Date
    Apr 2010
    Location
    Steamboat Springs
    Posts
    2,529
    Crosspost at http://www.access-programmers.co.uk/...te=1&p=1121208

    I have not been able to look at your example as I am currently on my machine that runs AC 2002. I will look later in the day when time allows.

  13. #13
    orange's Avatar
    orange is offline Moderator
    Windows XP Access 2003
    Join Date
    Sep 2009
    Location
    Ottawa, Ontario, Canada; West Palm Beach FL
    Posts
    16,726
    Alan,

    Your example with =Text0.Column(1) and the dlookup approach yield the same result.

    Is there an issue?

  14. #14
    pwalter83 is offline Novice
    Windows XP Access 2007
    Join Date
    Dec 2011
    Posts
    19
    Quote Originally Posted by orange View Post
    Alan,

    Your example with =Text0.Column(1) and the dlookup approach yield the same result.

    Is there an issue?
    What Alan suggested was to add the field to the combobox to use it further in the textbox. This is where I have the problem, my textbox already uses an autopopulated value which neither can be edited nor can be used to add another field.

  15. #15
    orange's Avatar
    orange is offline Moderator
    Windows XP Access 2003
    Join Date
    Sep 2009
    Location
    Ottawa, Ontario, Canada; West Palm Beach FL
    Posts
    16,726
    10-4. It wasn't clear to me why his method wasn't acceptable. I opened his mdb and it seemed to work fine. Now that I reread post 9, I see the issue.
    Thanks for clarifying.

Page 1 of 2 12 LastLast
Please reply to this thread with any new information or opinions.

Similar Threads

  1. 2 Combo boxes and 1 textbox autopopulate
    By csjackson in forum Programming
    Replies: 2
    Last Post: 12-16-2011, 10:51 AM
  2. Replies: 1
    Last Post: 06-21-2011, 03:34 AM
  3. Replies: 3
    Last Post: 05-26-2011, 12:52 PM
  4. Replies: 9
    Last Post: 09-23-2010, 10:42 AM
  5. Lookup from Textbox
    By mastromb in forum Forms
    Replies: 4
    Last Post: 01-02-2010, 07:59 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