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 strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

How do I make a Combo box show 2 fields or more in a drop down, like M

Status
Not open for further replies.

fmasin

Technical User
May 3, 2002
163
GB
Hi,

I have a combo on my form - I would like this combo to show Surname, DateofBirth and postcode to ensure that the record selected is the rightful one - how I can I do this? Please...

Thanks and regards,

Francis
 
You want to have all of that data shown on one combo box? Seems a bit much to me. If all of your data is a one-to-one(-to-one, etc) match, it would not be necessary to do this at all. If one surname matches only one DOB and one postcode, just show the surname and add the other data on the backend (without showing it unnecessarily on the front end). Otherwise, I might be more inclined to use multiple combo boxes.

If you have additional questions on how to accomplish these ideas, feel free to ask (or search on these forums since at least the second option has been covered previously).

------------------------------------------------------------------------------------------------------------------------
"I am not young enough to know everything."
Oscar Wilde (1854-1900)
 
So how can I show the surname and date of birth in one combo box?

Thanks and regards,

Francis
 
Code:
<%
'pretend our data is in dataA and dataB
Response.Write "<select name=""whatever"">"
Response.Write "<option>" & dataA & " " & dataB & "</option>"
Response.Write "</select>"
%>

or

<%
'pretend our data is in dataA and dataB
%>
<select>
<option><%=dataA%> <%=dataB%></option>
</select>

barcode_1.gif
 
Tarwn,

Thanks for this....however, what if I want to pull 2 fields from the same table all to show in the drop down combo but when I click, it will just pick one to show in the text area?

For example...select surname,postcode from tblClient...and I want the combo to show the client's surname and postcode to minimise duplicate names and only show the surname on Select... How would I do that?

Thanks and regards,

Francis
 
Tarwin,

It's something like this...

<tr>
<td width="194">Select Name</td>
<td width="424">
<p align="left">

<select size="1" name="Client_Id" style="width: 310; height: 310">
<%
sql = "Select * from tblClient ORDER BY SurName"
rs.open sql,myconn,3,3
do until rs.eof
%>
<option value = "<%=rs("Client_Id")%>" ><%=rs("Surname")%></option>
<option value = "<%=rs("Client_Id")%>" > <%=rs("DateOfBirth")%> </option>

<%
rs.movenext
Loop
rs.close
%>
</select>
</td>
</tr>

This code here shows both fields in the combo box but does not show them on the same line - so in this case it shows surname and then DOB. How would I get them to show on the same line?

Thanks and regards,

Francis
 
Hi

Many thanks for your code but unfortunately it's generating the following error.

Error Type:
Microsoft VBScript runtime (0x800A01F4)
Variable is undefined: 'jpsvbBuildOption'
OCH/CaseEntry.asp, line 105


How do I resolve it?

Thanks and regards,

Francis
 
Sounds like you might be missing one or both of these lines of code which are in devtip-filllistbox-sample.asp:

<!--#include file="devtip-filllistbox-sample-config.asp"-->
<!--#include file="devtip-filllistbox-sample-jpsutilityabbr-WithComment.asp"-->

Best regards,
J. Paul Schmidt, Freelance Web and Database Developer
Access Database Sample, Web Database Sample, ASP Design Tips
 
Bullschmidt

I have actually included both files... and included the following in my code;

<% ' Dim var.
Dim objjpsvbBuildOption
Dim strSQL
Dim Client_Id
%>

<tr>
<td align="right">Client No | SurName | FName</td>
<td>
<% ' Set sql.
strSQL = "SELECT Client_Id, SurName, FirstName "
strSQL = strSQL & "FROM tblClient "
strSQL = strSQL & "ORDER BY SurName, FirstName"
%>
<select style="font-family:Courier New,Lucida Console" size="1"> <% ' Fixed space font. %>
<% ' Create, use, destroy object.
Set objjpsvbBuildOption = New jpsvbBuildOption
objjpsvbBuildOption.DefaultValue = Client_Id
objjpsvbBuildOption.FldWidths = "10|15|8"
objjpsvbBuildOption.AddedRowFlds = ""
Call objjpsvbBuildOption.Execute(MyConn, RS, strSQL)
Set objjpsvbBuildOption = Nothing
%>
</select>
</td>
</tr>
==========================================================
Unfortunately, I'm getting the following error:

Error Type:
Microsoft VBScript compilation (0x800A0411)
Name redefined
OCH/devtip-filllistbox-sample-config.asp, line 3, column 4

===========================================================What I have in the config.asp is as follows:

<%
'Option Explicit
Dim myConn, myDb, RS, rs2, StrSQL
Set myConn=server.createobject("ADODB.connection")
myDb = "Driver={Microsoft Access Driver (*.mdb)};DBQ=e:\OCH\LawAssist.mdb"
myConn.open myDb
set RS = server.createobject("ADODB.Recordset")
set rs2 = server.createobject("ADODB.Recordset")
%>

====================================================

What could be the problem?



Thanks and regards,

Francis
 
Sounds like this is in both the included page and on the main page:

Set myConn=server.createobject("ADODB.connection")

Best regards,
J. Paul Schmidt, Freelance Web and Database Developer
Access Database Sample, Web Database Sample, ASP Design Tips
 
Extrapolating from Tarwn's example:

[tt]
<option value="<%=rs("Client_Id")%>">
<%=rs("Surname") & " " & rs("Client_Id")%>
</option>
[/tt]
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top