Solved FAYT Listbox crashes Access (1 Viewer)

ClaraBarton

Registered User.
Local time
Today, 09:19
Joined
Oct 14, 2019
Messages
605
I'm using MAJP's FindAsYouTypeListbox. I have a dialog popup where I select a record and then close and return to calling form. Wlhen the popup closes, the code goes to mListBox_Afterupdate which calls Unfilterlist. This code crashes the program:
Code:
Private Sub unFilterList()
  On Error GoTo errLable
  Set mListbox.Recordset = mRsOriginalList
   Exit Sub
Since I've already closed the popup, I don't know why this code is called. The following is how I close the form:
Code:
Private Sub lstChild_AfterUpdate()
    If IsNull(TempVars("ChildID")) Then           'empty TempVars
        TempVars.Add "ChildID", 0
    End If
    TempVars("ChildID").Value = Me!lstChild.Value
    
DoCmd.Close acForm, Me.Name

End Sub
What am I doing wrong?
 
The FAYT combo has a lot of functionality and flexibility which is more difficult to roll your own. Not so much with the listbox. You probably can roll your own faster then chasing down the issue. Likely this is causing an event loop where an event calls another event calling the original event.
 
I agree with the loop problem... but I really like how it searches. Could I or How would I call Class_Terminate from my form? Wouldn't this stop it before closing?
 
I'm using MAJP's FindAsYouTypeListbox. I have a dialog popup where I select a record and then close and return to calling form. Wlhen the popup closes, the code goes to mListBox_Afterupdate which calls Unfilterlist. This code crashes the program:
Code:
Private Sub unFilterList()
  On Error GoTo errLable
  Set mListbox.Recordset = mRsOriginalList
   Exit Sub
Since I've already closed the popup, I don't know why this code is called. The following is how I close the form:
Code:
Private Sub lstChild_AfterUpdate()
    If IsNull(TempVars("ChildID")) Then           'empty TempVars
        TempVars.Add "ChildID", 0
    End If
    TempVars("ChildID").Value = Me!lstChild.Value
   
DoCmd.Close acForm, Me.Name

End Sub
What am I doing wrong?
No idea, however FYI, I have never used .Add for Tempvars, just
TempVars("ChildID").Value = Me!lstChild.Value

if it did not exist it is created, if it does exists it is updated.
 
So you filter then select and close. I would try setting the fayt variable to nothing before closing. Although this should theoretcially all take care of itself.

Code:
Private Sub lstChild_AfterUpdate()
    If IsNull(TempVars("ChildID")) Then           'empty TempVars
        TempVars.Add "ChildID", 0
    End If
    TempVars("ChildID").Value = Me!lstChild.Value
'Terminate the class by setting it to nothing
 Set nameOfyourFAYT = nothing   
DoCmd.Close acForm, Me.Name

End Sub
 
Oh Yes yes! you make it seem so easy! Thank you.

One more little, tiny thing... When working with a keyboard, tab doesn't work to jump from the selection box to the list box. A mouse selects the record fine, but I'd like to make it a little more smooth. How do I jump to the listbox from the search box?
1708805303140.png
 
Isn't that just using the Tab order?
 
As @Gasman said that should be just the tab order. But there may be a bigger feature to add. Once you tab into the list, I have it set up so once you make a selection the list unfilters. If you want to tab in then use the arrows I would have to add some features. But not sure of the logic then to determine when to unfilter. It could be set up to unfilter only on hitting return.
 
tab order does not work. I'll try some other things. Thanks for your help.
 
Make sure the tab stop is not set to No.
 

Users who are viewing this thread

Back
Top Bottom