Listbox Database

J

Jonathan

Hi Everyone,

How do I make the contents of a Listbox source a database table - i.e. I
have one table that users updated with codes that are used when inputting
info. At the moment I have to edit each list box and manually add them as
options, I would like the list box to pick up the options from a database to
make it more automated even though the target DB for submission will be
different in the end, does this make sense to you?

Tia

J
 
S

Stefan B Rusynko

Create your "listbox" table in your DB and open that table w/ your DB connection (say as objRS1) in addition to the table you are
writing data to (say as objRS)
To display the listbox (with a field named Subject) use

<select name="Subject" size="1">
<%
objRS1.MoveFirst
Do While Not objRS1.EOF
%>
<option value="<%=objRS1("Subject")%>"><%=objRS1("Subject")%></option>
<%
objRS1.MoveNext
Loop
%>
</select>

The value selected for Subject would be written to objRS("Subject") in you main table



| Hi Everyone,
|
| How do I make the contents of a Listbox source a database table - i.e. I
| have one table that users updated with codes that are used when inputting
| info. At the moment I have to edit each list box and manually add them as
| options, I would like the list box to pick up the options from a database to
| make it more automated even though the target DB for submission will be
| different in the end, does this make sense to you?
|
| Tia
|
| J
 
M

MD Websunlimited

Hi Jonathan,

Use the DRW to produce a drop down then modify the generated code to change the size of the dropdown to produce a "Listbox"
 
A

Andrew Murray

If you're using the Database results wizard, it gives you the option to display
the results from an Access Database in a drop down box, which can then be
inserted in a form, to form the basis for a search.
 
Top