Dynamic List Problem

1. Senior Member
Join Date
Dec 1969
Posts
349

Dynamic List Problem

Here is the code as it stands. The problem is that if there is no match between theroom("room") = myarray(9,i) for a particular record, I need the option list dropdown to default to myarray(9,i) but allow users to be able to choose another value from theroom("room"). <BR><BR>roomdrop = ""<BR><BR>While not theroom.eof<BR> if theroom("room") = myarray(9,i) then<BR> roomdrop = roomdrop & "&#060;option selected value=" & chr(34) & theroom("room") & chr(34) & "&#062;" & theroom("room") & "&#060;/option&#062;"<BR> else<BR> roomdrop = roomdrop & "&#060;option value=" & chr(34) & theroom("room") & chr(34) & "&#062;" & theroom("room") & "&#060;/option&#062;"<BR> end if<BR> <BR> theroom.movenext<BR> wend<BR> theroom.close<BR>

2. Junior Member
Join Date
Dec 1969
Posts
16

RE: Dynamic List Problem

Be Lazy!<BR><BR>I assume that myarray(9,i) contains a valid room, and from the code above you want the option box to default to myarray(9,i) regardless of the contents of theroom("room"). If so don&#039;t bother to check the list. Just put your default at the top, and accept the fact that this default may appear more than once on the list. Not "slick" I know, but easy any faste than a loop with conditional statements in.<BR><BR>roomdrop = "&#060;option selected value=&#039;" & myarray(9,i) & "&#039;&#062; " & myarray(9,i) & "&#060;/OPTION&#062;"<BR><BR>While not theroom.eof <BR> roomdrop = roomdrop & "&#060;option value=&#039;" & theroom("room") & "&#039;&#062;" & theroom("room") & "&#060;/option&#062;" <BR><BR> theroom.movenext <BR>wend<BR><BR>theroom.close

3. Senior Member
Join Date
Dec 1969
Posts
349

RE: Dynamic List Problem

I was hoping to avoid having the item appearing more than once in the list...

4. Junior Member
Join Date
Dec 1969
Posts
16

Appearing once

In that case use the code you suggested, and simply check that the roomdrop variable contains the word "selected". If not then you know the default was not in the room list, so you need to add it.<BR><BR>After the Wend statement add<BR>If InStr(roomdrop,"selected")&#060;1 then &#039;InStr returns 0 if item is not part of string<BR> roomdrop=roomdrop & "&#060;OPTION selected value=&#039;" & etc etc here<BR>End If<BR><BR>This will work fine, but note that a loop with an If clause in it is slow, so my previous suggestion still stands!<BR><BR>Have fun.<BR><BR>Steve<BR>

Posting Permissions

• You may not post new threads
• You may not post replies
• You may not post attachments
• You may not edit your posts
•