View Single Post
  #3 (permalink)  
Old 11-15-2008, 02:39 AM
Salad
Guest
 
Posts: n/a
Default Re: What is causing this OnClick event?

DavidGeorge wrote:
> I have been receiving a lot of help from Salad on this issue and I'm
> delighted to say that he has come up with the answer!
>
> When Salad looked at the problem using Access97 and could not
> reproduce the problem; the form worked exactly as one would expect.
> However a form created in Access 2003 exhibited the strange behaviour
> I described. But the best bit is that, even when he imported this
> Access 97 form into Access 2003 it still worked!
>
> Armed with this knowledge, and a form created in Access 97 I imported
> the form into my application and then copied the ListBox into my
> application. It works brilliantly.
>
> Thank you Salad!


You are welcome.

I have no idea what I did so that it would work on some forms vs not
work on others.

If anyone wants to see this in action...here's what you do.
Create a new form
Create a listbox, List0, and type in the values
one
two
three
four
Set the listbox's Multi-select to extended.

Drop another listbox (List2) onto the form. Hit cancel.
Set the rowsource to ValueList.

Drop this code into the form's module
Option Compare Database
Option Explicit
Const QT = """"

Private Sub List0_Click()
Dim var As Variant
Dim strRow As String

For Each var In Me.List0.ItemsSelected
strRow = strRow & QT & Me.List0.Column(0, var) & QT & ";"
Next
If strRow > "" Then strRow = Left(strRow, Len(strRow) - 1)
Me.List2.RowSource = strRow
If strRow > "" Then Me.List2.Selected(0) = True

End Sub

Now run the form. Select some items in List0. You will not be able to
set focus to List2. Somehow I got this to work tho but I have no idea
why. There appears to be no difference between the form that works and
the form that doesn't if I compare the property sheets.

Oh well.
Reply With Quote