Solved FAYT Listbox crashes Access (2 Viewers)

ClaraBarton

Registered User.
Local time
Today, 00:52
Joined
Oct 14, 2019
Messages
463
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?
 

MajP

You've got your good things, and you've got mine.
Local time
Today, 03:52
Joined
May 21, 2018
Messages
8,529
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.
 

ClaraBarton

Registered User.
Local time
Today, 00:52
Joined
Oct 14, 2019
Messages
463
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?
 

Gasman

Enthusiastic Amateur
Local time
Today, 08:52
Joined
Sep 21, 2011
Messages
14,301
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.
 

MajP

You've got your good things, and you've got mine.
Local time
Today, 03:52
Joined
May 21, 2018
Messages
8,529
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
 

ClaraBarton

Registered User.
Local time
Today, 00:52
Joined
Oct 14, 2019
Messages
463
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
 

Gasman

Enthusiastic Amateur
Local time
Today, 08:52
Joined
Sep 21, 2011
Messages
14,301
Isn't that just using the Tab order?
 

MajP

You've got your good things, and you've got mine.
Local time
Today, 03:52
Joined
May 21, 2018
Messages
8,529
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.
 

ClaraBarton

Registered User.
Local time
Today, 00:52
Joined
Oct 14, 2019
Messages
463
tab order does not work. I'll try some other things. Thanks for your help.
 

MajP

You've got your good things, and you've got mine.
Local time
Today, 03:52
Joined
May 21, 2018
Messages
8,529
Make sure the tab stop is not set to No.
 

Users who are viewing this thread

Top Bottom