Microsoft Access Forums

Go Back   Microsoft Access Forums > Access Forums > Programming

Reply
 
LinkBack Thread Tools Display Modes
  #1  
Old 08-07-2006, 05:24 AM
Novice
 
Join Date: Aug 2006
Location: Lake City, Forida
Posts: 5
ocordero
Default Creating a string from all records in a table

I use the following code to build a string from items selected in a listbox by the user:
__________________________________________________ _______
Private Sub SendEmail_Click()

Dim varItem As Variant
Dim strTO As String

For Each varItem In Me.lstTO.ItemsSelected
strTO = strTO & ",'" & Me.lstTO.ItemData(varItem) _
& "'"
Next varItem

End Sub
__________________________________________________ _______

I would like however, to avoid having the user select the items but rather, build the string automatically from the table or at least have the code use all the items in the listbox, which are the same items in the table since I'm populating the listbox from the table. Any ideas?
Reply With Quote
  #2  
Old 08-07-2006, 06:19 AM
Advanced Beginner
 
Join Date: Dec 2005
Posts: 99
StepUP
Default

Code:
For varItem = 0 To Me.lstTO.ListCount - 1
    strTO = strTO & ",'" & Me.lstTO.ItemData(varItem) & "'" 
Next varItem
__________________
John F
Reply With Quote
  #3  
Old 08-07-2006, 07:21 AM
Novice
 
Join Date: Aug 2006
Location: Lake City, Forida
Posts: 5
ocordero
Default

It worked like a charm. It was so simple I'm almost embarrassed.

Thanks JohnF.
Reply With Quote
Reply

Bookmarks

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are Off
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Problem creating new records using old values on same table. gailoni Programming 0 10-22-2008 10:08 PM
Creating top values with two records avesamuel Queries 0 10-15-2007 08:45 PM
Delete all records in a table? bob646 Access 1 05-20-2007 09:41 PM
How do I hide inactive records when creating a report in Acc emily at KU Reports 1 12-06-2006 02:32 PM
Selecting and modifying records in a table Ed H Access 1 03-17-2006 09:04 AM


All times are GMT -8. The time now is 03:03 PM.


Powered by vBulletin® Version 3.8.4
Copyright ©2000 - 2010, Jelsoft Enterprises Ltd.
SEO by vBSEO 3.3.2 ©2009, Crawlability, Inc.