For I = x to x , next

hbrems

has no clue...
Local time
Today, 11:16
Joined
Nov 2, 2006
Messages
181
Hello,

I got a table which looks like this:

# | e-mail
--------------
a | me@x.com
b | me@x.com
c | you@x.com
d | he@x.com
e | he@x.com
f | he@x.com

Please note that column '#' is a reference number in the actual environment.

I need to write a function which sends an e-mail to all of these people, together with the reference numbers that are linked to them.

Example: to he@x.com I will send an e-mail which includes references d,e & f. but I don't want to send 3 seperate e-mails.

Probably I'll need some kind of 'for i = a to b; next' function to go through my table. Or maybe there's a better alternative? Can somebody give me more information about this function specifically?

Kind regards,
Hans B.
 
You want to open a recordset, which is an in-memory subset of records and fields in a table.
A fast & dirty example looks like...
Code:
Dim dbs as dao.database
Dim rst as dao.recordset
dim email as string
dim body as string

email = "he@there.com"
set dbs = currentdb
set rst = dbs.openrecordset( _
  SELECT [#] FROM YourTable WHERE email = '" & email & "'")
with rst
  do while not .eof
     body = body & ![#] & vbcrlf 
     .movenext
  Loop
  .close
end with

sendmail email, body
 

Users who are viewing this thread

Back
Top Bottom