Refreshing combo box list

G

Guest

Access 2000

I've got Form A, which has a combo box with a list of items from Table B.
The combo box has the focus when I open the form. If the item I want isn;t
in the list I can use the bottun on the form to open Form B, which allows me
to add a record to Table B.

I close Form B, which leaves me back at Form A where I want the new record
to appear in my combo box.

I've tried using the OnClick and OnEnter events for the combo box with both
the DoCmd.requery and the xxx.requery methods but neither cause a requery to
happen.

Here's the code I've tried:

Private Sub Combo20_Click()
Dim ctlLstBox As Control
Set ctlLstBox = Me!Combo20
ctlLstBox.Requery
End Sub

And:

Private Sub Combo20_Click()
Dim ctlLstBox As Control
Set ctlLstBox = Me!Combo20
DoCmd.requery ctlLstBox
End Sub

Looking at this I now wonder if the Me! is the problem?? I used that
because the form has a space in the name.
 
K

kingston via AccessMonster.com

One way to do this is to explicitly change the combobox RowSource property
first:

Me.Combo20.RowSource = newSQLstring
Me.Combo20.Requery

newSQLstring could be something like:

"SELECT * FROM [Table B];"
 
M

Marshall Barton

LauriS said:
Access 2000

I've got Form A, which has a combo box with a list of items from Table B.
The combo box has the focus when I open the form. If the item I want isn;t
in the list I can use the bottun on the form to open Form B, which allows me
to add a record to Table B.

I close Form B, which leaves me back at Form A where I want the new record
to appear in my combo box.


The key to this kind of arragement is to open formB in
dialog mode so code execution in your button is suspended
until formB closes. Then you can do the requery.

DoCmd.OpenForm "formB", WindowMode:= acDialog
Me.combo.Requery
 

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