Wrox Programmer Forums

Need to download code?

View our list of code downloads.

Go Back   Wrox Programmer Forums > Microsoft Office > Access and Access VBA > Access VBA
Password Reminder
Register
| FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read
Access VBA Discuss using VBA for Access programming.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the Access VBA section of the Wrox Programmer to Programmer discussions. This is a community of tens of thousands of software programmers and website developers including Wrox book authors and readers. As a guest, you can read any forum posting. By joining today you can post your own programming questions, respond to other developers’ questions, and eliminate the ads that are displayed to guests. Registration is fast, simple and absolutely free .
DRM-free e-books 300x50
Reply
 
Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old August 14th, 2004, 10:04 PM
Registered User
 
Join Date: Aug 2004
Location: , , .
Posts: 2
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via AIM to dholcomb
Default newbie - Query to String

Hi,

Actually I have been using VBA to control my access applications for years, but I haven't been able to figure out how to do what I would suspect is a very SIMPLE thing. I don't have any hair left to pull out: Help!

So I have this command-button on a form, which creates a new table based on a lot of information I select on that form. I also have a query based on this table which gets rid of unnecessary duplicate information.

I want to create a (somewhat lengthy) string from the query based on two fields ([Person] & [e-mail]) for all of the records in the query.

Is it obvious where I am going with this? I can open my e-mail client, and send a message using VBA, I just can't figure out how to get the addresses I want into the send field.

Thanks for any help!
Reply With Quote
  #2 (permalink)  
Old August 16th, 2004, 03:19 AM
Authorized User
 
Join Date: Aug 2004
Location: , , .
Posts: 54
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Something like this :-

Code:
    '- RECIPIENTS
    For rw = 1 To Addresses.Rows.Count
        If Addresses.Cells(rw, 1).Value <> "" Then
            MailRecipient = Addresses.Cells(rw, 2).Value
            MyRecipients.Add (MailRecipient)
        End If
    Next
-----------------------
Regards BrianB
Most problems occur from starting at the wrong place.
Use a cup of coffee to make Windows run faster.
It is easy until you know how.
Reply With Quote
  #3 (permalink)  
Old August 16th, 2004, 03:23 AM
Authorized User
 
Join Date: Aug 2004
Location: , , .
Posts: 54
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Sorry, left off this bit, where MyItem is the name I give to the MailItem :-
Code:
Set MyRecipients = MyItem.recipients
-----------------------
Regards BrianB
Most problems occur from starting at the wrong place.
Use a cup of coffee to make Windows run faster.
It is easy until you know how.
Reply With Quote
  #4 (permalink)  
Old August 16th, 2004, 09:44 AM
Registered User
 
Join Date: Aug 2004
Location: , , .
Posts: 2
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via AIM to dholcomb
Default

Thanks Brian. I have to admit that I am completely lost with what you are suggesting. I have been working along these lines:
 
Code:
            Dim cnn As ADODB.Connection
Code:
            Dim rst As ADODB.Recordset
            Dim varOutput As Variant
            Dim strQuery As String

            Set cnn = CurrentProject.Connection
            Set rst = New ADODB.Recordset
            strQuery = "SELECT person, e-mail " & _
                        "FROM [Export Table e-mail Query]"

            rst.Open strQuery, cnn, adOpenStatic, adLockReadOnly, adCmdText

            If rst.RecordCount > 0 Then
            'Use all defaults: get all rows, TAB column delimiter, CARRIAGE RETURN
            'row delimiter, empty-string null delimiter
                varOutput = rst.GetString(adClipString)
                Debug.Print [Person] & " <" & [e-mail] & ">"
                Debug.Print varOutput
            Else
                Debug.Print "No names found to e-mail to" & vbCr
            End If

            rst.Close
I am using borrowed code here, and trying to adapt it to my needs (everyone does this, right?), but I can't get past the "rst.open" command. Ther error tells me that there is "No value given for one or more required parameters." I can't find sufficient help on these parameters. I'll admit that I don't really know what I am searching for, but I can't find anything. Once I get the rst opened, I was also going to try:

Code:
        Do Until rst.EOF
            If strTo <> "" Then
                strTo = strTo & ", "
                End If
            strTo = strTo & [Person] & " <" & [e-mail] & ">"
            rst.MoveNext
        Loop
Again more borrowed code modified for my use.

Thanks again for any help.

Reply With Quote
Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search
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 Off
HTML code is Off
Trackbacks are Off
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Query string value SKhna ASP.NET 2.0 Basics 1 March 17th, 2008 07:27 AM
this Newbie has adp / stored query problems - LeoTiger1 BOOK: Access 2003 VBA Programmer's Reference 0 June 13th, 2006 03:40 PM
newbie question- cutting a string apart harpua BOOK: Beginning PHP, Apache, MySQL Web Development ISBN: 978-0-7645-5744-6 1 June 21st, 2005 04:53 AM
Query String Baby_programmer ASP.NET 1.0 and 1.1 Basics 3 December 24th, 2004 11:14 AM
Query String Nitin_sharma VBScript 1 December 16th, 2004 07:58 AM



All times are GMT -4. The time now is 02:22 PM.


Powered by vBulletin®
Copyright ©2000 - 2019, Jelsoft Enterprises Ltd.
© 2013 John Wiley & Sons, Inc.