I have a form (frmTST_Maintenance) which adds, changes, deletes and browses records in a table CUS. Upon opening, I have created a filter that points it to a record in CUS based upon a CUS_ID stored in a static local table. That static table holds the CUS_ID until/unless a different record is pointed to and operated upon in CUS.
A "Browse" button click in frmTST_Maintenance opens another form -- a popup form -- (frmTST_Browse) using cmdBrowse_Click() event which contains " DoCmd.OpenForm 'fmTST_Browse' " to call the browse form with the maintenance form open/visible in the background. That browse form allows the user to scan through records in CUS and "select" one of those records. The selection of a record causes the CUS_ID of that new record to be stored in the static local table. The browse form then closes leaving the maintenance form which is still visible.
What is supposed to happen is that the maintenance form should be re-reading the local static table to obtain the new CUS_ID, create a new filter, and display the newly browsed/selected record. For the life of me I cannot get this process to properly occur without artificially/manually "refreshing" the maintenance form via a phony button that I created for that purpose but that I need to manually click in order to get the maintenance form to react to the new filter and display the new record.
The browse button code looks like:
Private Sub cmdBrowse_Click()
' call the browse form
' after returning from the browse form, read the latest value from the local static table
' and establish the filter on CUS so as to show the latest selected record ID
If g_GetSTAValue("STA_CUS_ID") <> 0 Then
Me.Filter = "[CUS_ID] = " & g_GetSTAValue("STA_CUS_ID")
Me.FilterOn = True
I cannot get the filter lines to fire AFTER the opening of the browse form. They want to file BEFORE the line that opens the browse form is executed. I have confirmed this with msgbox bracketing the filter if/then lines. If I msgbox before the browse form open line I get (let's say CUS_ID = 30). If I place another msgbox after the filter lines, it still gives me the CUS_ID = 30 (even though in the browse selection form I selected CUS_ID = 33, and in addition, BOTH msgbox commands fire before the browse open line executes.
I have tried to bracket the browse open and if/then with me.refresh, me.requery, me.repaint, form_current(), form_activate(), form_open() -- everything that I can think of, but I cannot get the filter to take effect AFTER the browse selection without manually clicking other buttons on the maintenance form which then "magically" fires the filtering and the redisplay of the new record.
If anyone out there can tell me what is going on, I would REALLY appreciate it.