Results 1 to 2 of 2
  1. #1
    namazu is offline Novice
    Windows 7 64bit Access 2010 64bit
    Join Date
    Mar 2016
    Posts
    1

    Show data value in Access table in textbox with reference to selection of value in Combobox

    Dear All,



    Recently, I want to create a form, where having 2 areas: 1) is the combobox, which list all the values in a field of a Table and 2) a text box that I want to show a value in a table corresponding to the selection in the combobox.

    The example is described further as below

    1. Data
    Data is recorded in table name "people", in which there are 2 columns: Name and Std_Rate (Standard Rate). Name is full name of multiple persons in the tables.

    2. Combobox
    This combobox, when click, will appear all Name recorded in the people table as described above. This step is straighforward and easy in Ms Access

    3. Textbox

    Textbox is shown in the same form with the combobox.

    when the a Name in the Combobox is clicked (selected), I want the textbox to show exact value of Standard Rate for that selected person.

    I tried following code but when viewing the form and select a Name from combobox, the standard rate does not appear.

    Private Sub Combobox1_Click()
    Dim a As String
    a = Me!Combobox1.Column(1)
    Me!Textbox1 = DLookup("[Std_Rate]", "people", "[Name]='a'")
    End Sub

    -------------------------------------------

    I tried to test the value a to a specific person and it works. For example,



    Private Sub Combobox1_Click()
    Dim a As String
    a = Me!Combobox1.Column(1)
    Me!Textbox1 = DLookup("[Std_Rate]", "people", "[Name]='Peter Acheta'")
    End Sub

    --------------------------
    Here the name of a person "Peter Acheta" is defined in Dlookup, and it works, but when I change to a as a value selected from combobox, it doesnt work.

    Please help me to solve this issue.

    Thanks you and appreciate your supports.



    Nam

  2. #2
    ranman256's Avatar
    ranman256 is offline VIP
    Windows Vista Access 2010 32bit
    Join Date
    Apr 2014
    Location
    Kentucky
    Posts
    9,525
    You don't have to do a DLOOKUP if your value is in the combo box.
    the combo box will show name but the text box gets the other value...
    txtBox = cboBox.column(1)
    but your cboBox columns propery must be set to 2.

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

Similar Threads

  1. Show data in textbox
    By razzel in forum Forms
    Replies: 5
    Last Post: 12-26-2014, 01:01 PM
  2. Replies: 3
    Last Post: 11-05-2014, 02:43 AM
  3. Replies: 3
    Last Post: 11-25-2013, 08:23 PM
  4. Replies: 4
    Last Post: 02-09-2012, 03:03 AM
  5. Combobox selection updates Table record
    By lucky in forum Access
    Replies: 4
    Last Post: 10-30-2011, 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