this piece of code crashes Access

jatfill

Registered User.
Local time
Today, 06:18
Joined
Jun 4, 2001
Messages
150
Hi all,
I'm reworking an existing database from the ground up & I've encountered an odd problem that occurs as a result of a procedure I'm building into a form.

Essentially, what I'm doing is this: I have a form that displays a parent's information, and then below there are a series of tabs that contain details about that parent's account. Each parent can have multiple students, so the first tab is a list of students for that parent record. Each of the subsequent tabs has charge, payment, schedule, and notes. The way I set this up was that each list of charges, etc. was based on whichever student record was selected on the list (so if there were multiple students, picking/adding the records to work with would be pretty clear to the end user).

So what I was trying to do is write a procedure so that when the parent form is opened, if that parent only had one child, the child was automatically selected in the list box. So I put in the following:

Code:
Private Sub Form_Current()
Me.lstStudents.Requery
Me.lstTelephone.Requery
Me.lstSchedule.Requery
Me.txtStudent.Value = ""

If Me.lstStudents.ListCount = 2 Then
    Me.lstStudents.Selected(1) = True
    Exit Sub
Else
    Exit Sub
End If

End Sub

The IF..ELSE part of this statement produces the following error in Windows 2000:

"The instruction at '0x300c627e' referenced memory at '0x00000060'. The memory could not be 'read'."

Removing the if portion of the statement makes the error go away... so I'm assuming this code is somehow inaccurate, or it could point to more serious issues....

Any ideas on the issue would be greatly appreciated. Thanks!
 

Users who are viewing this thread

Back
Top Bottom