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