Re: Dynamic Drop Down List Problem

From: Joe Van Meer (vanmeer_at_accesscable.net)
Date: 03/14/04


Date: Sun, 14 Mar 2004 12:41:05 -0400

Hi there,

Have you considered using the ID for the value and just displaying the name
in the option? That way your update gets based on an ID rather than a name
which could be a duplicate in the database.

Here's some code I have, notice the ID in the value in the option tag:

<select name="groupid" size='1' style="font-family: Arial; font-size: 7pt;
border:1 solid #000000;">
  <%
    WHILE NOT grouprs.EOF
    curGroupId = clng(grouprs("GroupID"))
    %>
    <option value="<%= curGroupId %>"><%=grouprs("GroupName")%></option>
    <%
    grouprs.MoveNext
    wend
    grouprs.Close
    set grouprs = nothing
    connectionToDB.close
    Set connectionToDB = Nothing
    %>
      </select>

Hope this helps, Joe

"melody" <anonymous@discussions.microsoft.com> wrote in message
news:b8c701c407f1$df7d9a80$a401280a@phx.gbl...
> I am using Access 2000 and Win2K. I have an asp page that
> lets users edit / update a particular record from a form.
> The form has a drop-down list box that is populated from a
> recordset (e.g. rsNames). The option in the drop-down list
> that gets selected is the value that is stored in the
> database for that particular record. I am using this code
> to accomplish this :
>
> <select name="Names">
> <option value="">- Please select from list -</option>
> <%
> While (NOT rsNames.EOF)
> %>
>
> <option value="<%=(rsNames.Fields.Item("SName").Value)%>"
> <%if (CStr(rsNames.Fields.Item("SName").Value) = CStr
> (rsCandidates.Fields.Item("CandidateName").Value)) then
> Response.Write("SELECTED") : Response.Write("")%> ><%=
> (rsNames.Fields.Item("SName").Value)%></option>
>
> <%
> rsNames.MoveNext()
> Wend
> If (rsNames.CursorType > 0) Then
> rsNames.MoveFirst
> Else
> rsNames.Requery
> End If
> %>
> </select>
>
> The above code works in most cases. My problem is that the
> code is not working for several records I have in my
> Access database (the option that corresponds to the
> database value is not selected in the drop-down list).
> These records in particular have been exported from an
> Excel 2000 spread*** into Access. I have checked the
> value stored in those database records with the option
> value in the drop down list and the values are the same
> (I do not see any difference between 'ROBERT QUINN' in the
> drop-down list option and 'ROBERT QUINN' in the database
> value....).
>
> I really do not know how to get around this and would
> appreciate any help or suggestions.
>
> Many thanks in advance,
> melody
>