PDA

View Full Version : Repeated/Looping Fields in a TextBox


jedirobb
08-06-2006, 10:26 PM
ASP Pages
Access 2003 Database

I have a table (tbl_Investors) with contact information in it; one of the fields is an email address (fldPrimEmail).

I am trying, with minimal success, to have a single text field on my form be populated with the email address for each of the records in the table with a "; " between each for email purposes.

When the form populates now it creates multiple text boxes with a separate email address and "; " in each.

I know I am looping the text field and that is why it is displaying as such but I cannot figure out how to just loop the database field and send that value to the single text box.

Here is the value I am using for my text box that goes repeat crazy on me:
<%= rstDBEdit.Fields("fldPrimEmail").Value %>;

Thanks much for any help you can offer.

Brandoe85
08-06-2006, 10:41 PM
Hi,

You could create a variable that you would concatenate each email onto with the ';'. Then after your done looping put the value of the variable in the text box.

Good luck;

jedirobb
08-06-2006, 11:12 PM
I figured as much but I cannot come up with the syntax to do so... I do not get how to concatenate the same field, separate fields sure, but not the same one...

You have an example I could work with?

Thanks.

Brandoe85
08-06-2006, 11:32 PM
If I understand you correctly:

Dim strEmails

' put this in your loop
strEmails = strEmails & rstDBEdit.Fields("fldPrimEmail").Value & ";"

' after your loop

<input type="text" value="<%= strEmails %>">


Untested, but should give you an idea.

Good luck;

jedirobb
08-07-2006, 12:32 AM
Perfect, just what I needed to get it rolling!

I added a couple of "< >" in there to separate the email addresses and it works like a champ...

Thank you much for your help!

:thumbsup:

Brandoe85
08-07-2006, 12:34 AM
Cool, you're welcome :)