Question : Fire an update event to a form's controls when lookup table is modified

Description:
1. A Form's combo-box control displays values from a lookup table.
2. When an unknown entry is typed in the control it generates a "_NotInList" event.
3. In the "_NotInList" event, a form to modify (add the entry) the lookup table is opened.
4. The new data are entered and saved.
5. After closing down the lookup table form the control's (1.) contents are NOT displayed in the drop-down list.

Question:
How can I force the control to "refresh" its contents?

Answer : Fire an update event to a form's controls when lookup table is modified

In the data entry form's OnClose event you can do something like this:

Sub LookUpForm_Close()
    Forms!MainForm!Combo1.Requery
End Sub

If the lookup form might be used when the main form is not open, you can do this:

Sub LookUpForm_Close()
    If isFormOpen("MainForm") Then
        Forms!MainForm!Combo1.Requery
    End If
End Sub

Here is the code for the isFormOpen routine:

Function isFormOpen(strName As String) As Boolean
   isFormOpen = (SysCmd(acSysCmdGetObjectState, acForm, strName) <> 0)
End Function

Random Solutions  
 
programming4us programming4us