combo box update?

  • Thread starter Thread starter Jian
  • Start date Start date
J

Jian

Hi,
Is there a way to update a combo box's listing in a first
open form (A form) while the user is on a different data
entry form (B form) to input the new data? That means A
form and B form are both open, while once the user
entered and saved the new data in B form and closed B
form, the A form is still open, but without doing
anything, the combo box's listing connected to the data
entered from B form should be added into the combo box
listing on the A form. Any suggestion on this will be
greatly appreciated.
jian
 
in Access Help, search for ComboBox Object. then, under Events, select the
NotInList Event. the topic explains how to do what you're asking.
 
Thank you - Tina, but you didn't understand what I was
asking for.

anybody understand my question below, please I need your
help. Thanks,Jian
 
You need to do a requery on the combo box on Form A. Unfortunately, though,
Form A has no way of knowing the Form B closed.
 
Jian,

Why not tag a Requery of the combo box on form A to the
OnClose event of form B??

Forms!MyFormA!MyComboBox.Requery

Regards,

Xcelsoft
 
----- Douglas J. Steele wrote: ----

You need to do a requery on the combo box on Form A. Unfortunately, though
Form A has no way of knowing the Form B closed

would the On Current event be a good spot? formB may not have closed, but it might have updated the data
 
no offense, but Tina directed you to an explanation of how to do the task you are describin

if that doesn't satisfy you, then try performing a search here using "NotInList event" as the search. others have had the same problem you are havin

alot of solutions will actually open 'formB' when the combobox on 'formA' gets a 'not in list' event. the code opens the second form and then waits until the second form closes to continue running, when it does you can then run any updates on the data the form use

do you have any code written for this yet? if so, try posting it so others can inspect/help/offer suggestion

hth
 
not to buff anybody but the not in list event tricks are only helpfull when
you add data in the said combobox
you do need to do a requery when adding data in another form...
I prefer however to put the requery on the after insert event of the form
instead of using the close event & retain the value of the Combo

Pieter

anonymous said:
no offense, but Tina directed you to an explanation of how to do the task you are describing

if that doesn't satisfy you, then try performing a search here using
"NotInList event" as the search. others have had the same problem you are
having
alot of solutions will actually open 'formB' when the combobox on 'formA'
gets a 'not in list' event. the code opens the second form and then waits
until the second form closes to continue running, when it does you can then
run any updates on the data the form uses
do you have any code written for this yet? if so, try posting it so
others can inspect/help/offer suggestions
 
anonymous said:
----- Douglas J. Steele wrote: -----

You need to do a requery on the combo box on Form A. Unfortunately, though,
Form A has no way of knowing the Form B closed.

would the On Current event be a good spot? formB may not have closed, but it might
have updated the data

To trigger the OnCurrent event, you have to move to a new record.

I suppose you could put something in Form A's OnActivate event, so that it
does something when it regains the focus. Of course, as you pointed up, that
does mean Form B has been closed, nor that it's updated the data.
 
here's the solution i came up with. it assumes that the purpose of opening
the second form is to add a record to the source table of the combo box in
the first form.

Private Sub Combo0_NotInList(NewData As String, Response As Integer)

If MsgBox("Do you want to add a new color to the list?",
vbDefaultButton1 + vbYesNo) = vbYes Then
DoCmd.RunMacro "Macro1.open form"
Response = acDataErrAdded
Else
Response = acDataErrContinue
Me!Combo0 = Null
Me!Combo0.Dropdown
End If

End Sub

the form i opened fronts a table of colors, which table is also the
RecordSource in the combo box. in the "open form" macro, the Window mode is
set to Dialog. as stated in the Open Form help topic, opening the form in
Dialog suspends the macro until the form is closed. unfortunately, i did not
observe the same (necessary) suspension when using DoCmd.OpenForm in VBA,
instead of calling the macro.
(A2000 db format in A2003 on Win2000Pro OS)
 
In the On Close property for Form B put this code:
[Forms]![FormA]![ComboBoxName].Requery

This will update the box in Form A, but Form B will no longer wor
properly if called from other forms
 
Back
Top