How to put the last date into my textbox in the form

Ahmeds

New member
Local time
Today, 22:56
Joined
Apr 5, 2016
Messages
4
ow to put the last date into my textbox in the form
Hi there.. I would like to ask for a little help here.
I have a combo box in a form and a two textbox, what i want to do is if I choose in a combo box item the value in the textbox would change too.

The table i am working is like this. Table with 3 columns

|--Field 1--|--Field 2--|--Field 3--|
| AAA | 12000 | 1/2/2016 |
| BBB | 12000 | 1/3/2016 |
| CCC | 12000 | 1/3/2016 |
| AAA | 24000 | 2/4/2016 |
| CCC | 24000 | 2/5/2016 |
| BBB | 24000 | 2/16/2016|
| AAA | 36000 | 3/9/2016 |
| DDD | 12000 | 4/1/2016 |

Sample: If i change the value of the combobox into AAA the textbox1 get the value of the latest date(Field 3) which is 3/9/2016 and the texbox2 get the value of field 2 which is 36000.

Hope you help me with this. Thanks!
 
If you want the record to show in the form, set the filter
Code:
 vDate =dmax("[date]","table","[field1]='" & cboBox & "'")
Me.filter ="[date]=#" & vDate & "# and [field1]='" & cboBox & "'"
Me.filterOn = true
 
Thank you... but as a newbie I really don't know how to do it yet. Where and How to put your codes. sorry for that. But I really appreciate your help.
 
Code:
Private Sub Combo0_Click()
    With CurrentDb.OpenRecordset("SELECT top 1 [field 3], [field 2] FROM Table1 WHERE [field 1]='" & Combo0 & "' order by [field 3] desc")
        textbox1 = .Fields(0)
        textbox2 = .Fields(1)
    End With
End Sub
 

Users who are viewing this thread

Back
Top Bottom