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 gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Listclick Problem

Status
Not open for further replies.

ZOR

Technical User
Jan 30, 2002
2,963
GB
I have an event of a list click. If I click on the list, code is run which includes a query to fill another list. It works okay. However if I click on the list and use the up/down keybord arrows it halts displaying a notice -

The macro or function set to the BeforeUpdate or ValidationRule property for this field is preventing Microsoft Office Access from saving the data in the field.

There is nothing in either of the mentioned events, and nothing is being saved? its just finding records.
If the arrow keys are moved slowly theres no problem.

Code for the listfill that gives the problem is:

MySQL2 = "SELECT AthleteNames.AthleteID, AthleteNames.Athlete, AthleteNames.Country, "
MySQL2 = MySQL2 & " JUNCTION.ID2, AthleteNames.SportorSports AS Sport FROM AthleteNames "
MySQL2 = MySQL2 & " INNER JOIN JUNCTION ON AthleteNames.AthleteID = JUNCTION.AthleteID "
MySQL2 = MySQL2 & " WHERE (((JUNCTION.ID2)=[forms]![Mainform1]![Subform1].[form].[ID2])) ORDER BY AthleteNames.Athlete;"

Me.AthleteList = ""
Me.AthleteList.RowSource = MySQL2

If I rem this out the problem goes. I tried putting DoEvents in different places but it does not cure it.

Hope its not a Service Patch 3 issue, thanks
 
Howdy ZOR . . .

What happens if you move your code from the [blue]On Click[/blue] event to the [blue]AfterUpdate[/blue] event of the combo?

Calvin.gif
See Ya! . . . . . .

Be sure to see thread181-473997
Also faq181-2886
 
Many thanks. Putting the code into the AfterUpdate event didn't fix it. I also tried putting the code into the oncurrent event and that did not work. The action of the code simply first sets the recordsource of the subform, and then fills the Athletes list. Also forgot to correct - The list getting clicked is a Listbox not a combo. Regards
 
I have found out my problem. After the line Me.AthleteList.RowSource = MySQL2 I have a DoEvents statement. I think it's this thats tripping itself up with a fast listscoll, as taking it out cures the problem. Can that be the case?, regards
 
Zor . . .

What I posted was a guess, due to not knowing if your clicking a seperate listbox from [blue]AthleteList[/blue] and wether this seperate listbox is on the main form! It appears so, as the MySQL2 references a subform. But I could be wrong . . .

Calvin.gif
See Ya! . . . . . .

Be sure to see thread181-473997
Also faq181-2886
 
Sorry if I confused you.

"I have an event of a list click. If I click on the list, code is run which includes a query to fill another list. It works okay. However if I click on the list and use the up/down keybord arrows it halts displaying a notice"

A listbox is on a subform. When clicked it sets the recordsource of the subform its on. Also in the same click event, another listbox on the same subform gets filled with related items to the subforms ID2 (Primary key) value.

Removing a DoEvent command that I had put after the line
Me.AthleteList.RowSource = MySQL2
cured the problem. Scrolling through the first list must have been too quick for the DoEvents action? probably not getting the time to do the DoEvents before seeing it requested again? only my theory

However thanks again, have a good weekend
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top