Combobox question?

  • Thread starter Thread starter ed
  • Start date Start date
E

ed

I have a combobox named "Drawing No" and a Listbox where
all the existing parts in the Part List_tbl are listed.
There is query attached to the Rowsource of the combox
which brings the drawing number from Drawing_tbl. The
value of the combobox changes as you select different
records from the list. I want to insert this combobox's
value (drawing no) into another table by clicking on a
command button. I tried everything but it doesnot work.
Because when I select different record from the listbox,
despite the value of the combobox changes it doesnot
disappear in the combobox unless you click on the little
arrow on the combobox. So after selecting the record from
the listbox, I have to go to combobox click on the arrow
and highlight the querried drawing no then it works.

Is there any easy way to do that? I used listbox instead
of combobox to bring up the drawing no but same thing. You
have to highlight it if you want to insert it.
 
Hi Ed,

how many records are there on your combo box when you select an item from the listbox?. If it is only 1 then you can try this line of code:

Private Sub Listbox_AfterUpdate()
Me.Combobox.Requery
If Me.Combobox.ListCount > 0 Then
Me.Combobox = Me.Combobox.ItemData(0)
End If
End Sub

If you set Column Heads Property in the combobox to Yes, then you have a slight different code:

Private Sub Listbox_AfterUpdate()
Me.Combobox.Requery
If Me.Combobox.ListCount > 0 Then
Me.Combobox = Me.Combobox.ItemData(1)
End If
End Sub

Hope this help.


----- ed wrote: -----

I have a combobox named "Drawing No" and a Listbox where
all the existing parts in the Part List_tbl are listed.
There is query attached to the Rowsource of the combox
which brings the drawing number from Drawing_tbl. The
value of the combobox changes as you select different
records from the list. I want to insert this combobox's
value (drawing no) into another table by clicking on a
command button. I tried everything but it doesnot work.
Because when I select different record from the listbox,
despite the value of the combobox changes it doesnot
disappear in the combobox unless you click on the little
arrow on the combobox. So after selecting the record from
the listbox, I have to go to combobox click on the arrow
and highlight the querried drawing no then it works.

Is there any easy way to do that? I used listbox instead
of combobox to bring up the drawing no but same thing. You
have to highlight it if you want to insert it.
 
Back
Top