Refresh Combo Box Data

K

K

Good day,

I have a combo box on a form (FrmMain) that selects information from a table
called TblPack. If I add info into the TblPack through another form aclled
FrmPack It does not diplay in the combo box unless I close the main form and
the reopen it. How do I correct this so when inof is added it updates the
combo box.

Thanks
 
K

Klatuu

The short answer is you have to requery the combo box to get any new records
added to the combo's record source.
The longer issue is knowing when a new record has been added. Is there any
relationship between the operation of the two forms?
 
K

K

Thanks for the response. Yes there is a relationship between the two
forms.(Two Tables) Main table has the field Packtype which is selected from
the pack table. One too many relationship between the two tables. I tried
refresh when the PackType form is closed. I also tried Requery when the combo
box - clicked on (Event)
 
K

Klatuu

Well, in your orginal post you said one table, two forms. Now you mention
two tables. I am a bit lost.
What I was getting at is what you originally described was if you add a
record using one form, how could you make is show in the combo box of another
form. This would indicate both forms are open at the same time.
Can you describe the situation in more detail please?
 
K

K

Sorry, I dont mean to confuse anyone. Yes there are two tables. One called
TblMain and another called TblPackType. in TblMain there is a field called
packing which is selected(combo box) from TblPacktype (Field = Type in this
table). The relationship is one toomany between the two tables joining fields
are Type to Packing.

Now on the form FrmMain the field from TblMain (Packing) is the combo box
beside it I have an edit button that opens the FrmPacking to enter new
information. After entering the new data I would like to have the combo box
updated witrh the newly entered information
 
K

Klatuu

After you close FrmPacking, requery the combo.
FrmPacking will need to be a modal form for this to work correctly. When
you open a modal form, code in the current module pauses until the modal form
closes.
So:

Docmd.OpenForm FrmPacking
Me.MyCombo.Requery
 
Top