barges
asked on
Unwanted loop when using On current event in Microsoft Access 2007
I have a form with two listboxes, two subforms and two pictureboxes.
1) The first listbox is populated via the row source in it.
When I mark a row in the listbox one subform show detail information and one picturebox show a linked picture.
I use the listbox After_update to populate the picturebox.
This works fine.
2) The second subform is linked to a textbox which is drawing the value from the listbox. The column in the subform is a foreign key, so I get a number of rows in the subform.
This works fine.
3) I have a textbox taking a value from the second subform. This textbox is used in the query populating the second listbox as a criteria.
When I mark a row in the second subform I want the second listbox to show values reflecting this.
To do this I have a requery in the second subforms event On current. I do the requery on the second listbox.
Here is the problem: A loop is started and the On current event is run over and over again.
I can not understand why because I do not trigg the On current event in the code, I do the requery on the listbox which is placed in the main form.
4) The last thing is that when I click on a row in the second listbox the second picturebox is populated.
This works fine except for that the loop is removing the picture from the second picturebox. (When I click on another row in any form or list the pictures are removed.)
I know this sounds a bit complicated but I have tried to keep the structure strait forward.
I upload the file (Access 2007) together with some picture files used in the example, and hope someone can tell me where I go wrong.
There is also a textfile with short instructions.
Best Regards,
Hans Hansson
Brandbilar-20111206.accdb
A.jpg
B.jpg
Bild1.jpg
Bild2.jpg
Bild3.jpg
Instructions.txt
1) The first listbox is populated via the row source in it.
When I mark a row in the listbox one subform show detail information and one picturebox show a linked picture.
I use the listbox After_update to populate the picturebox.
This works fine.
2) The second subform is linked to a textbox which is drawing the value from the listbox. The column in the subform is a foreign key, so I get a number of rows in the subform.
This works fine.
3) I have a textbox taking a value from the second subform. This textbox is used in the query populating the second listbox as a criteria.
When I mark a row in the second subform I want the second listbox to show values reflecting this.
To do this I have a requery in the second subforms event On current. I do the requery on the second listbox.
Here is the problem: A loop is started and the On current event is run over and over again.
I can not understand why because I do not trigg the On current event in the code, I do the requery on the listbox which is placed in the main form.
4) The last thing is that when I click on a row in the second listbox the second picturebox is populated.
This works fine except for that the loop is removing the picture from the second picturebox. (When I click on another row in any form or list the pictures are removed.)
I know this sounds a bit complicated but I have tried to keep the structure strait forward.
I upload the file (Access 2007) together with some picture files used in the example, and hope someone can tell me where I go wrong.
There is also a textfile with short instructions.
Best Regards,
Hans Hansson
Brandbilar-20111206.accdb
A.jpg
B.jpg
Bild1.jpg
Bild2.jpg
Bild3.jpg
Instructions.txt
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
I split the point between you.
Many thanks,
Hans