Combobox Afterupdate Event setting text box value

P

Pat

I am attempting to create a form to perform receiving of equipment and update
the asset tables with the equipment based on a location. When the form is
opened the first time, the data in the recordset is invalid. The
absoluteposition is -1. When you make another selection the reordset is
proper. BTW the combobox is bound to column 1 in the recordset. The text
box is updated from column 2.

I am using a unbound combobox (cboLocation) to query a table for a location
name. Then set a unbound textbox (txtLocID) with the location number.
Thisis the event I am using.

Private Sub cboLocation_AfterUpdate()
' Textbox - txtLocID
' Combobox - cboLocation - Uses the query below for data
' SELECT tblACOELocations.PHYS_LOC_N10, tblACOELocations.OLD_LOC_I
' FROM tblACOELocations
' ORDER BY tblACOELocations.PHYS_LOC_N10;

Me.txtLocID.SetFocus
Me.txtLocID = Me.cboLocation.Recordset.Fields("OLD_LOC_I").Value
Me.cboEmp.Requery
End Sub

Any help is appreciated.
 
D

Douglas J. Steele

All you should need is

Private Sub cboLocation_AfterUpdate()
' Textbox - txtLocID
' Combobox - cboLocation - Uses the query below for data
' SELECT tblACOELocations.PHYS_LOC_N10, tblACOELocations.OLD_LOC_I
' FROM tblACOELocations
' ORDER BY tblACOELocations.PHYS_LOC_N10;

Me.txtLocID = Me.cboLocation.Column(1)
Me.cboEmp.Requery
End Sub

Make sure that the ColumnCount is set correctly for the combo box, or you
won't be able to refer to the column.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top