Synchronize a combo-box and a text box

Bizkaiko

Registered User.
Local time
Today, 04:46
Joined
Jan 17, 2005
Messages
31
I've a form with a combo box "OrderNumber" (to allow the user to select the correct order) and a text box "Date" which displays the date of the order selected.
The problem is that I don't know how to synchronize the boxes.
I know the procedure to do it with two combo-boxes (cmboDate=Null & cboDate.Requery in the after update property of the cbo "Order Number"), but is it possible that when I change the order selected in the combo-box, the text box shows the correct date?
Thanks for your help!
 
combo box / date box

Hi Bizkaiko,

I use two possible approaches in this situation:

1) Use the DLookup function on the afterupdate event of the combo box e.g.
cmb_ordernumber_afterupdate

txt_date.value = DLookup("OrderDate","Orders","OrderNumber = '" & cmb_ordernumber.value & "'")

2) Put the date text box into a subform based on a query that is filtered by the selected order number.

Let me know if this is any help
 
You can use that code:

Sub ShowDate()
'Don't forget to define the YourComboBox.RowSource to YourTable
Set x = YourForm.RecordsetClone
x.FindFirst "[YourCodeField] = " & YourComboBox
If Not x.EOF Then YourForm.Bookmark = x.Bookmark
End Sub

Call that Sub on the YourComboBox Change Event.
 
Assuming the date for each order is stored along with the order details and is in one of your combo columns then it's just
=[YourCombo].[Column](1) as the control source for your textbox, where column1 is the second column in your combo
you should also note that Date is a reserved word in Access and shouldn't be used as a field name
 
OK, I used the DLookUp function & I solved the problem!
thanks ;)
 

Users who are viewing this thread

Back
Top Bottom