Avatar of Mark Lewis
Mark Lewis

asked on 

Need help with code on a web page

I have written a series of pages that pulls a list of names from an Access database for a pull down box on the initial entry form. The problem is getting that same form to list the names when I update the record. In a different web page I used the code below to return the list in a dropdown but the dropdown would also default to the selected value.

Set conntemp=Server.CreateObject("ADODB.Connection")
myDSN ="Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" & Server.Mappath("../../fpdb/My_Databse.mdb")
conntemp.open myDSN
mySQL = "SELECT DISTINCT ColumnName FROM TableName"
Set myRS = Server.CreateObject("ADODB.Recordset")
myRS.Open mySQL, conntemp, 0, 1
Set myRS = nothing
Set conntemp = nothing

<select size = "1" name= "Variable1">

For i = 0 to Ubound(arrName, 2)
Response.write("<option value="""& arrName(0,i) &"""")
If arrName(0,i)=fp_rs("Variable1") Then Response.Write(" Selected") End If

In the web page that's not working, I get my list but the drop down does not default to the value for variable1. I believe the reason for this is because on the page that works, the values for the drop down list are in the same table as the selected value where on the page that doesn't work, I need to pull the list from a different database, let alone a different table that where the data vaules are stored. I just dont know the fix.

To sum it up, I have two databases A & B wth tables 1 & 2. On my entry form, I am pulling names from A1  to a dropdown box and submitting those values to B2. When I go to update the record pulling values from B2, I need the update form to recreate the pulldown box pulling all the values from A1 again but defaulting to the value the record has in B2.

Dang, I hope this makes sense.
Microsoft AccessASPSQL

Avatar of undefined
Last Comment
Mark Lewis

8/22/2022 - Mon