Access Database/Visual Basic Anyone???

drivebymonkey

Advanced Member
Messages
444
Right, I'm trying to put my mum a database together for her client list. It started off with her just wanting a simple form so she could search for phone numbers, addresses etc. To make it a bit easier for her to do mail shots a set up a report that takes all the addresses and puts them onto labels, that was the easy bit!!

she now wants the same sort of thing for emails. I want to try and get it so it picks all the emails from the form, opens up a blank email and puts all the emails in "To:". there is around 1800 records, of which only about 500 have email addresses.

I tracked down this code on the internet:

----------------------------------------------------------

Dim rst As ADODB.Recordset
Dim sEmails As String
Set rst = New ADODB.Recordset
rst.Open "SELECT YourEmailField FROM YourTAbleName WHERE YourEmailField IS NOT NULL", CurrentProject.Connection

Do until rst.EOF
sEmails = rst("YourEmailField") & ";" & sEmails
rst.MoveNext
loop
'/now use SendObject
DoCmd.SendObject acSendNoObject, , , sEmails, , , "Subject", "body"


------------------------------------------------------------------

With my (very) limited knowledge of visual basic this seems to be the sort of thing i want, except the debugger picks up the first line as "User Defined is undefined".

any help to get this working would be great guys.

Thanks in advance!! :D
 

Tarmac

Advanced Member
Messages
759
You need to add a reference in your project to "Microsoft ActiveX Data Objects 2.6 Library". The 2.6 in that can be whatever version you have available like 2.0 or 2.5 etc either.

You are using early-binding in this code which requires you to directly reference the library in your project so you can do this.

Hope this helps
 
Top