Using Dynamically Populated Listbox

Results 1 to 3 of 3

Thread: Using Dynamically Populated Listbox

  1. #1
    PD Fins Guest

    Default Using Dynamically Populated Listbox

    I have an Access 97 database with an employee table containig the following fields: FName, LName, Email, Phone, Address.<BR>I&#039m using an SQL query to dynamically populate a listbox listing the names in a "LName, FName" configuration. How do I submit the selection to bring up the remainder of the selected employee&#039s info? Also, may be the same problem, but I don&#039t know what to use for my option values. Code as follows:<BR>WHILE NOT oRs.EOF<BR>strNames = strNames & "&#060;option value=" WHAT GOES HERE? & "&#062;" & oRs("LName") & ", " & oRs("FName") & "&#060;/option&#062;"<BR>oRs.MoveNext<BR>WEND

  2. #2
    Join Date
    Dec 1969

    Default RE: Using Dynamically Populated Listbox

    What goes in the "WHAT GOES HERE?" spot is the value that you want sent when the selected option is submitted. You probably want the first and last name but its whatever format the file called by the submit is expecting; it might look like this where your list box would display (last,first) and the value sent would be (first last):<BR><BR>strNames = strNames &_<BR> "&#060;option value=" &_<BR> oRs("FName") & " " & oRs("LName") & "&#062;" &_<BR> oRs("LName") & ", " & oRs("FName") & "&#060;/option&#062;" & vbCrLf<BR><BR>Try that.<BR>NOTE: The underscore (_) is VBScript to continue the next line.

  3. #3
    dumb_ass_a_rock Guest

    Default RE: Using Dynamically Populated Listbox

    Ideally, you would have an ID field in your table.<BR><BR>Then you could do:<BR> strNames = strNames & "&#060;option value=" & oRs("ID") & "&#062;"....<BR><BR>Then when the form gets posted, you can get the ID number from the Request object like this:<BR> EmpID = CLng(Request("ListBoxName"))<BR><BR>Then, run a query on this ID to get the rest of the employee&#039s informaiton.<BR> sSQL = "SELECT * FROM EmplyoeeTable WHERE ID = " & EmpID<BR> etc.<BR><BR>Hope that helps.<BR><BR>Frank Walton<BR>

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts