Problem closing a form with a combo box linked to a list box. (1 Viewer)

Essendon

Registered User.
Local time
Today, 05:09
Joined
Oct 25, 2001
Messages
65
Hi,

I have an annoying problem that I have literally spent hours trying to fix.

I have a single form that is used as a reports menu. Within it, I have a combo box with the names of schools in it. When I choose a school, a corresponding list box shows the students of that school. I can then choose a number of students at random from the list box and click a button to include them in a report.

My problem is that for some reason when I close the report menu form (ie the form with the combo/list box), I always get an input box asking for a value, then it returns to the main menu no matter what I do with the input box! I have spent hours trying to trace the problem. I have traced it down to the line of code that updates the list box when I change a value in the combo box: Me!cboStudentList.Requery (placed in the on change event of the combo box). I cant comprehend why this is occuring.

I am going to list all the details here:

***on change event of combo box (cboSchoolSelect)***

Private Sub cboSchoolSelect_Change()
Dim i As Variant
For Each i In Me![cboStudentList].ItemsSelected
Me![cboStudentList].Selected(i) = False
Next i

Me!cboStudentList.Requery
Me!cboStudentList.SetFocus
End Sub

***Record source for this combo box (cboSchoolSelect):***

SELECT Commercial_Schools.School_Code, Commercial_Schools.School_Name
FROM Commercial_Schools
ORDER BY Commercial_Schools.School_Name;

***Reocord Source for the list box that is updated(cboStudentList) yes it is a list box despite the "cbo" part of its name:***

SELECT Commercial.ID, Commercial.Name, Commercial.School, Commercial_Schools.School_Code
FROM Commercial_Schools INNER JOIN Commercial ON Commercial_Schools.School_Code = Commercial.School
WHERE (((Commercial.School)=[Forms]![Commercial Report Form]![cboSchoolSelect]));

Please Help!

[This message has been edited by Essendon (edited 04-09-2002).]

[This message has been edited by Essendon (edited 04-09-2002).]

[This message has been edited by Essendon (edited 04-09-2002).]
 

Fizzio

Chief Torturer
Local time
Today, 05:09
Joined
Feb 21, 2002
Messages
1,885
Try using the requery code in the after_update event of the combo rather than the on_change. If no joy, what is the input box asking for?

HTH
 

Users who are viewing this thread

Top Bottom