problem with '.selected' property

IfButOnly

Registered User.
Local time
Today, 12:24
Joined
Sep 3, 2002
Messages
236
I have had a problem in using the .selected property for some time and have been unable to resolve it. Originally when I used the property it would give me a fatal error and drop me out of Access. Currently, it locks up my form, except for the listbox that I am using it from.

I went to Microsoft with the problem and after deleting and reloading Office, the problem was still there so I sent them a sample DB with the problem. Feedback from them was it was a coding problem and would need to go to their professional services group and cost $300. I assume from that they were able to reproduce the problem.

Basically, I have two list boxes - Click on lstSites, populates lstJobs and builds string using a loop thru all the items in lstJobs - this is not how I intend to use it but as a demo of the problem.

Code is as follows:-
............................................................................
Private Sub lstSites_Click()
Dim Jobstring As String
Dim iloop As Integer

Me.lstJobs.Requery
Jobstring = ""
For iloop = 0 To Me.lstJobs.ListCount - 1
Me.lstJobs.Selected(iloop) = True
Jobstring = Jobstring & Me.lstJobs.Column(3) & ";"
Next iloop
Me.JString = Jobstring
End Sub

Private Sub lstJobs_Click()
MsgBox "clicked on Jobs Listbox"
End Sub
.............................................................................

On running the above, I can click on different items in lstSites and it populates lstJobs and Jobstring correctly, but I am unable to select anything else on the form - eg click on lstJobs should show the msgbox box but I locked out.

I was going to attach the demo application but don't have ZIP.

Appreciate any feedback whether it works for you or not.

Thanks in advance.
 
You should be able post your demo database (as long as it's not too large) by changing the file type to .Zip. As long as the system Thinks it's a .zip file it will accept it to be posted. Just make sure that people know to change the ".zip" to ".MDB" after they download it.
 
Thanks Drevlin, tried that but even with only 5 records in each table, one form, and the code above - my file was still 168k and too large to attach.

I will have another go when I get back this afternoon.
 
Hi, Peter,

Is the Multi-Select property on lstjobs set to either Simple or Extended? If not, set it to one of those two settings and try again...

Regards,
Tim
 
hey Pono - thanks very much that seems to have solved the problem with crashing and locking.

I had seemed to have resolved the problem in the demo by adding a reference - M/S VBA Extensibility 5.3. This fixed the demo but not my main app.

The problem I now have with the second list box set to simple - is that when I click on the box, I do a findrecord and bring up the record selected (from the second list box).

What happens is that when I click on the first listbox (client), it brings up all locations for that client (sites) in the second list box, selects the first item in Sites and displays that record details - all good. however, if I want to move to the third site in the list, I should just click on the 3rd item and it will bring up that record - with the multi select set if won't do that however - it will just show both the 1st and 3rd records selected.

I had hoped to just code around that by clearing all selects except the last - however that hasn't turned out so simple. Is there any way in a multi select to tell which item was just clicked.

I hope this makes some sense - thanks for your help to date.

peter
 
Got it going now. Problem was I was using Multi Select - Simple --- Extended does the job for me. Don't expect the user will use the ctrl or shift keys with it and even if they do it wont cause a problem.

many thanks for your help.
 
You're welcome. Glad to hear you got it sorted. (Moot info: you can use the ListIndex property to tell which item was just clicked in a listbox.)

Regards,
Tim
 

Users who are viewing this thread

Back
Top Bottom