[AccessD] MULTI SELECT LISTBOX dynamically selecting valuesfromanother listbox

Tom Keatley tom.p at piedpiper.com.au
Wed May 3 23:36:09 CDT 2006


Hi Stuart....

Hopefully the last one....

I have downloaded the code you suggested at tektips  and have installed it 
in a module within the database but now get a compile error with the message 
"cant Assign to an array" .... It must be the syntax?  I must admit this 
little wall is getting higher for me and I am considering finding another 
way.

For some reason the other code (without split) you did for me is giving me a 
type mismatch error so I made strCurrentValue into a string and the code 
appeared to run giving all the correct numbers and iterating through the 
listbox (in the debug window) but no lines were selected....

can you shed any light?


        Dim intI As Integer
        Dim intl2 As Integer
        Dim strIDValue As String
        Dim strIDs() As String
        Dim strCurrentValue As String ''

        strIDValue = "13772,13773,13771"

        strIDs() = Split(strIDValue, ",")
        For intl2 = 0 To UBound(strIDs)
          strCurrentValue = strIDs(intl2)
          For intI = 0 To Me!listcon1.ListCount - 1
             If Me!listcon1.ItemData(intI) = strCurrentValue Then
                Me!listcon1.Selected(intI) = True
             End If
         Next intI
       Next intl2


        strIDValue = 13771
        For intI = 0 To Me!listcon1.ListCount - 1
           If Me!listcon1.ItemData(intI) = strIDValue Then
              Me!listcon1.Selected(intI) = True
           End If
        Next intI
regards

Tom Keatley

----- Original Message ----- 
From: "Stuart McLachlan" <stuart at lexacorp.com.pg>
To: "access Developers discussion and problem solving" 
<accessd at databaseadvisors.com>
Sent: Thursday, May 04, 2006 11:09 AM
Subject: Re: [AccessD] MULTI SELECT LISTBOX dynamically selecting 
valuesfromanother listbox


> On 4 May 2006 at 9:59, Tom Keatley wrote:
>
>> Hi Stuart.....
>>
>> It seems when you assist me it always is with a Split function <grin>
>>
> That's because it's a very useful function :-)
>
>> My problem in this case is this database is in A97 ....No split
>> function .... Any Idea how I can solve it WITHOUT using Split?
>>
>
> You can get an A97 Split function, along with A97 versions of several 
> other A2K functions at
> http://www.tek-tips.com/faqs.cfm?fid=4342
>
> I'd suggest you keep them all in a module that you can paste into your 
> apps on demand :-)
>
>
>
>
> If you don't want to use Split(), you could do it this way:
>
> Dim intI As Integer
>       Dim intl2 As Integer
>       Dim strIDValue As String
>       Dim lngCurrentValue As Long
>       strIDValue = "73221,7259,13771,2"
>
>        strIDValue = strIDValue & ","  'to pick up the last value in the 
> loop below
> Do
>        lngCurrentValue = Val(strIDValue) 'get the first number
>        strIDValue = Mid$(strIDValue, InStr(strIDValue, ",") + 1) 'get rid 
> of the first number
>
>          For intI = 0 To Me!listcon1.ListCount - 1
>             If Me!listcon1.ItemData(intI) = lngCurrentValue Then
>                Me!listcon1.Selected(intI) = True
>             End If
>         Next intI
> Loop Until InStr(strIDValue, ",") = 0
>
> -- 
> AccessD mailing list
> AccessD at databaseadvisors.com
> http://databaseadvisors.com/mailman/listinfo/accessd
> Website: http://www.databaseadvisors.com
>
>
> -- 
> No virus found in this incoming message.
> Checked by AVG Free Edition.
> Version: 7.1.392 / Virus Database: 268.5.3/331 - Release Date: 03/05/2006
>
> 




More information about the AccessD mailing list