Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Access list box, vbScript and HTML

Status
Not open for further replies.

furtivevole

Technical User
Jun 21, 2001
84
GB
I have taken over maintenance of someone else's .asp pages. These use vbScript (new to me), and there are a lot of other unknowns which makes it trickier/riskier to try things out than it would usually be.

One of these is a web-based form, from which (among other things) the user has to select a Customer. Currently this is from a hard-coded list (i.e. with a series of <option>cust_name</option> tags).

We would like instead to read the customer list dynamically from an Access table.

I'm stuck on how best to do this. For instance, using vbScript, if I read the table into an array (declared as public), could I then use this to populate the HTML list box - or is there a more elegant method? Depends presumably on the scope of the array variable outside the vbScript code.

Any ideas please?

Linnet

 
This example uses VBScript and Active Server Pages
You will need to save the new page as a .ASP (Active Server page) which means your Site has to support Active Server Pages.

Next :
you need to create a Connection string to the Access database, and store it in a global.asa file.
I use Front Page and let it do the hard work for me.

I copy my Access databae to the WEB inside Front page and it prompts if I want to put it in the fpdb folder and make a connection (which I answer yes and have all that is needed).

this should work
----------------------
<html>
<%@ Language=VBScript %>
<head>
<title>Choose Customer Sample</title>
</head>

<body>
<%
Set fp_conn = Server.CreateObject(&quot;ADODB.Connection&quot;)
Set fp_rs = Server.CreateObject(&quot;ADODB.Recordset&quot;)
fp_conn.Open Application(&quot;customer_ConnectionString&quot;)
fp_rs.Open &quot;customers&quot;, fp_conn, 1, 3, 2 ' 2=Table 1=SQL Statement
fp_rs.movefirst
%>

<form method=&quot;GET&quot; action=&quot;yourwebpage.asp&quot;>
<p><select size=&quot;1&quot; name=&quot;Customers&quot;>
<%do while not fp_rs.eof%>
<option><%=CustomerName%></option>
<%fp_rs.movenext%>
<%loop%>
<%set fp_rs = nothing%>
<%set conn = nothing%>
</select></p>
<p><input type=&quot;submit&quot; value=&quot;Submit&quot; name=&quot;B1&quot;><input type=&quot;reset&quot; value=&quot;Reset&quot; name=&quot;B2&quot;></p>
</form>

</body>

</html>
-------------------------------



DougP, MCP

Visit my WEB site to see how Bar-codes can help you be more productive
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top