Refering a column (1 Viewer)

Rashid

Member
Local time
Today, 01:33
Joined
Sep 6, 2019
Messages
30
i have a ms db with employee info when i click a button a message sent to first employee of the table.but i want to send for all employees in the field so how can i refer a hole column by using recordset
 

arnelgp

..forever waiting... waiting for jellybean!
Local time
Today, 16:33
Joined
May 7, 2009
Messages
19,249
can you use an Update query:

Currentdb.Execute "Update yourTableName set [messageField] = '" & [yourMessage] & "';"
 

theDBguy

I’m here to help
Staff member
Local time
Today, 01:33
Joined
Oct 29, 2018
Messages
21,581
Are you talking about sending an email message? You'll need to loop through the records. This code snippet might help.
 

Pat Hartman

Super Moderator
Staff member
Local time
Today, 04:33
Joined
Feb 19, 2002
Messages
43,603
i want to send for all employees in the field
Why would you ever have more than one employeeID in a field? That isn't the way relational databases work! Each field is atomic. Meaning it has one and only one value.

If you are going to mush data this way, you need to learn how to write VBA code loops.
 

The_Doc_Man

Immoderate Moderator
Staff member
Local time
Today, 03:33
Joined
Feb 28, 2001
Messages
27,395
Pat, there are two ways to read that request. I think you read too much into it.

@Rashid, there is no built-in mechanism to, in a single operation, include EVERY mail address in a table. It has to be programmed. You can do multi-user send operations but it requires you to write a code loop to step through a recordset and pick out one user at a time to concatenate the addresses. You would do this BEFORE you send the message.

The relevant part of preparing to send a message is to load a "To" field in the message header. This field can hold more than one address. Note that there can be limits to the number of addresses you can load based on string size limits that depend on your mail sender program.

In your recordset loop, you would extract each targeted user address followed by a semi-colon ( ; ) and concatenate it into the TO header field. This assumes you are doing this with a standard SMTP-based sender such as Outlook or CDO. Once you have finished the loop, you can then send out your message.

Take a look at what theDBguy offered in his code snippet as a possible example.
 

Users who are viewing this thread

Top Bottom