Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chriss Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

RowSource Redefined and Access Shuts Down

Status
Not open for further replies.

traingamer

Programmer
Jun 18, 2002
3,270
US
I inherited a project with some odd behaviors.
I have a subform that has a listbox that chooses the active record on the subform. After deleting the active record (using a command button), delFlag is set to true, and there may or may not be a current record.

To choose a new current record, the doubleclick event on the list box does a FindFirst on (rs = Me.Recordset.Clone). This triggers the Form_Current event which HAD code like:
Code:
Private Sub Form_Current()   
If delFlag Then
        delFlag = False
        If bAnotherFlag = True Then
            Me.lstDetails.RowSource = "SELECT (code removed)
        Else
            Me.lstDetails.RowSource = "SELECT (code removed)
        End If
Else
        Me.lstDetails.Requery
End If
end sub
This would sometimes cause the entire application to just close with no warnings or messages at all.
I've replaced that with
Code:
Private Sub Form_Current()   
        delFlag = False
        Me.lstDetails.Requery
end sub
and things seem to be working just fine. Can anybody tell me why this was the case? Is it because the RowSource was redefined and not requeried? There seems to be no reason to redefine the RowSource as it is already defined in the Form_Load.

Greg
"Personally, I am always ready to learn, although I do not always like being taught." - Winston Churchill
 
I don't know if any of the below really relates to what you've described, but just throwing out some guesses...

When Access shuts down without any warnings, or display the "we're sorry for the inconvenience", my first suspicion is always corruption, and I've found that the db will most often be willing to accept a "healing" through the /decompile option.

In some instances, when some code is calling/triggering other code, Access can get a little confused. Though not related, have a look at this thread702-1025547, and the link in the original question.

Resetting a listbox rowsource is one of the more reliable ways of deselecting when using multiselect. Sometimes, a requery doesn't seem to do the job, but resetting does.

Roy-Vidar
 
Roy-Vidar, thanks for the response. The listbox in question didn't allow multiselect so that probably wasn't a problem. Just tried a /decompile - had never done that before. I regularly compact and repair this application.

Will test some more.

Greg
"Personally, I am always ready to learn, although I do not always like being taught." - Winston Churchill
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top