List Box Jumping To First Record

Groundrush

Registered User.
Local time
Today, 13:40
Joined
Apr 14, 2002
Messages
1,376
Greeting All!

I mentioned this a while back but was never able to solve this problem.

I don't have any nails left to chew so I hope some smart person on this forum can spot the error or know how to solve it.

Here goes...

On the main form you have a building that you can click on, once you have done so it will then list all the fire fighting appliances in that building that need servicing.

The problem is that when I'm editing the records the list box jumps to the first record after saving it & you have to scroll to the last record again to continue.

It's not so bad if you only have a few records to edit but it is a pain when you have more than can fit on the form.

I hope someone can spot where I'm going wrong and help me out as I have no idea how to solve this.

Thanking you in advance.
 

Attachments

Last edited:
Solution Found

Glad I found a solution. I modified your EnableAll function. See attached zip file.
 

Attachments

I like your thinking but it does the oposite now,it jumps to the last record... :D

I'm looking for a way to stay on the selected record once it's been updated instead of jumping.



Thanks for taking the time to look at it... :)
 
Changed the Column order in LstDetails and the search recordset bit, and added a bit of code to the save button.

HTH

Dave
 

Attachments

Thanks OldSoftboss for having a go.. :)

It still isn't working though, the records now vanish and it overwrites the first record when saving or something like that, it's gone all weird.... :D



It's funny how something you think is simple gets so complicated... :(

Cheers.
 
You said this:
Groundrush said:
.... & you have to scroll to the last record again to continue...

Now I know what you meant, the last edited record, not the last record of the list. That's can be easily changed.

More mods added to your cmdOk_Click and EnableAll subs.
 

Attachments

A simple save record command will not move the focus to another record. Are you requerying the data? If so... Why? Is it really needed?

If so... then this might help you go back to the current record... Requery causes record change
 
supercharge said:
You said this:


Now I know what you meant, the last edited record, not the last record of the list. That's can be easily changed.

More mods added to your cmdOk_Click and EnableAll subs.

Thats it!!... :)


I see you added CurEditRec = lstDetails.ListIndex to the CmdOk
& Me.lstDetails.Selected(CurEditRec + 1) = True to EnableAll

Thank you




ghudson said:
A simple save record command will not move the focus to another record. Are you requerying the data? If so... Why? Is it really needed?

If so... then this might help you go back to the current record... Requery causes record change

Thanks Ghudson
Sometimes it's difficult actually trying to figure out a way to describe a problem and knowing what to search for, I did a search on listbox jumping & that did not bring up many results... :D

Cheers
 
Last edited:
supercharge said:
Now I know what you meant, the last edited record, not the last record of the list. That's can be easily changed.

More mods added to your cmdOk_Click and EnableAll subs.

Iv'e just found that your solution only works with records that are viewable in the list box.
As soon as more are added and the scroll bar is used to select the record to be edited, it then jumps again.. :confused:
 

Attachments

I looked at the attached file and it worked alright to me. It may look to be jumping around but that same record is still highlighted. The reason why it looks like jumping is because your listbox can only show that many records at once. After you scroll the listbox up or down to hide the selected record and then click Save, the listbox will locate and show automatically the just-edited record on screen.
 
Isn't it a pain when you can't get something to work properly :mad:

I have another similar db that works perfectly but for the life of me I can't replicate the structure to work on this one.

I would love to know why it jumps in the first place I thought it may have something to do with the relationships and primary keys or something.

anyway life goes on.. :rolleyes:

Thanks for your help

cheers :)
 

Users who are viewing this thread

Back
Top Bottom