Combo Box contents

  • Thread starter Thread starter Krisse
  • Start date Start date
K

Krisse

My form has a combo box that is working fine. The data
source is a query that sorts a lookup table in
alphabetical order.

In case the value desired is not yet in the lookup table,
I also have a command button to open a form to allow the
addition of a new value into the lookup table.

The new value is not immediately visible on the drop
down. How do I accomplish this?

Thanks!
 
Krisse said:
My form has a combo box that is working fine. The data
source is a query that sorts a lookup table in
alphabetical order.

In case the value desired is not yet in the lookup table,
I also have a command button to open a form to allow the
addition of a new value into the lookup table.

The new value is not immediately visible on the drop
down. How do I accomplish this?

Assuming that the "add item" form is always called from this first form:
In the AfterUpdate event of the form used to add new items put code...

Forms!NameOfFirstForm!NameOfComboBox.Requery

If there will be times when the calling form will be different or the "add item" form
is used on its own, then you would need to add code to handle these situations. I
would likely put the calling form's name in the OpenArgs property of the "add item"
form where it could be tested by the AfterUpdate event code.
 
myComboBox.Requery

HTH

--
Rebecca Riordan, MVP

Designing Relational Database Systems
Microsoft SQL Server 2000 Programming Step by Step
Microsoft ADO.NET Step by Step

http://www.microsoft.com/mspress

Blessed are they who can laugh at themselves,
for they shall never cease to be amused...
 
-----Original Message-----
My form has a combo box that is working fine. The data
source is a query that sorts a lookup table in
alphabetical order.

In case the value desired is not yet in the lookup table,
I also have a command button to open a form to allow the
addition of a new value into the lookup table.

The new value is not immediately visible on the drop
down. How do I accomplish this?

Thanks!
.
Hi,

I have a form that works just like yours and I had the
same problem, me not very good with code so when I click
the command button to open my add record form I close the
first form with the combo box on it. Then when I close
the add new record form I have it open the original form
with the combo box on it and when it opens the new record
is displayed in the list. Hope this helps.
 
Thanks, Rick! I'll give this a try.
-----Original Message-----


Assuming that the "add item" form is always called from this first form:
In the AfterUpdate event of the form used to add new items put code...

Forms!NameOfFirstForm!NameOfComboBox.Requery

If there will be times when the calling form will be
different or the "add item" form
 
Thanks Dirk!

-----Original Message-----


The simplest way: in the command button's code, open the "add item"
form as a dialog form, thus pausing the code until that form is closed.
Then in the next line, requery the combo box. For example,

Private Sub cmdAddItem_Click()

DoCmd..OpenForm "frmAddItem", WindowMode:=acDialog

Me.cboItems.Requery

End Sub

--
Dirk Goldgar, MS Access MVP
www.datagnostics.com

(please reply to the newsgroup)


.
 
Thanks Rebecca!

-----Original Message-----
myComboBox.Requery

HTH

--
Rebecca Riordan, MVP

Designing Relational Database Systems
Microsoft SQL Server 2000 Programming Step by Step
Microsoft ADO.NET Step by Step

http://www.microsoft.com/mspress

Blessed are they who can laugh at themselves,
for they shall never cease to be amused...




.
 
Back
Top