Solved

List box syntax

Posted on 2004-10-18
3
177 Views
Last Modified: 2012-05-05
Hi

I have an update form that populates a number of list boxes with data from a secondary recordset. What I would like to be able to do is display the current record values from the primary recordset when the update form is first displayed rather than just seeing the list options from the seconday recordset. The user can then change the current value if they wish. Below is the code from one field. Can someone please advise me of the correct syntax.
thanks
Verdy


        <select name="Brk1" >  'from RSday
          <%
While (NOT RSBreakfast.EOF)
%>
<option value="<%=(RSBreakfast.Fields.Item("Breakfast_Item_Name").Value)%>"><%=(RSBreakfast.Fields.Item("Breakfast_Item_Name").Value)%></option>
          <%
  RSBreakfast.MoveNext()
Wend
If (RSBreakfast.CursorType > 0) Then
  RSBreakfast.MoveFirst
Else
  RSBreakfast.Requery
End If
%>
        </select>
0
Comment
Question by:verdante
3 Comments
 
LVL 7

Expert Comment

by:rohanbairat3
ID: 12343128
Sorry didnt get the question .... please explain in detail....

If its updating the values into second listbox depending on selection in first you should post back the form to itself and handle it there...

If you are more clear .. i will help u out
0
 
LVL 15

Accepted Solution

by:
gladxml earned 200 total points
ID: 12344490
I am not sure if I understood the question correctly.

assuming that your recordobject name is rs for the primary recordset which hold the
actual value and the fieldname is feild1 then this can be written as

rs("field1") which is also similar rs.Fields.Item("field1").Value

 Now to have a default value which the actual value of the primary recordset then you can try something like this

        <select name="Brk1" >  'from RSday
          <%
While (NOT RSBreakfast.EOF)
%>
<option value="<%=RSBreakfast("Breakfast_Item_Name")%>" <%if RSBreakfast("Breakfast_Item_Name") = rs("field1") then response.write "selected"%>><%=(RSBreakfast("Breakfast_Item_Name")%></option>
          <%
  RSBreakfast.MoveNext()
Wend
If (RSBreakfast.CursorType > 0) Then
  RSBreakfast.MoveFirst
Else
  RSBreakfast.Requery
End If
%>
        </select>


HTH...

Happy programming...
0
 

Author Comment

by:verdante
ID: 12346769
Love your work gladxml. It certainly did help. Very happy customer
Verdy
0

Featured Post

Live: Real-Time Solutions, Start Here

Receive instant 1:1 support from technology experts, using our real-time conversation and whiteboard interface. Your first 5 minutes are always free.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

I have helped a lot of people on EE with their coding sources and have enjoyed near about every minute of it. Sometimes it can get a little tedious but it is always a challenge and the one thing that I always say is:  The Exchange of information …
This demonstration started out as a follow up to some recently posted questions on the subject of logging in: http://www.experts-exchange.com/Programming/Languages/Scripting/JavaScript/Q_28634665.html and http://www.experts-exchange.com/Programming/…
Two types of users will appreciate AOMEI Backupper Pro: 1 - Those with PCIe drives (and haven't found cloning software that works on them). 2 - Those who want a fast clone of their boot drive (no re-boots needed) and it can clone your drive wh…
This video shows how to use Hyena, from SystemTools Software, to bulk import 100 user accounts from an external text file. View in 1080p for best video quality.

785 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question