It seemed simple at the time...
Ask for their email addresses, then when I have a list of people to contact, I can make my Access database spit the addresses out for me...
Here's my quandry:
I have a table (related to other tables in my database)that simply lists [Name][EmailAddress] and [ContactNumber]. I use a few queries to sort everything out and end up with usually about 5-10 people listed that need an email to remind them of delinquent entries. I have an Outlook template all made up and ready - and I figured I could grab the email addresses pretty easily (never tried this before - but hey - Access should make this part easy, right?)
After learning that there doesn't seem to be a built in function for this, I figured maybe I should try to send these addresses to a textbox in my form (hidden from view) and just use vba to plug that value into the To: line...
After a LOT of frustration, I am stumped. I know it's probably something simple - but for the life of me, I cannot figure this out! All of the threads I read are either for how to build an email in vba (which I already can do) or how to concatenate different values on a row...
I need (I think) to be able to concatenate the values from one COLUMN in my query into a textbox, and I can carry it from there.
(My SQL and VBA skills are amateur, so if you have the time to respond, please explain it to me like I'm a 10 year old!)
Thanks in advance for your help!
Dave
11 2145
So basically you are going to have to run some VBA to get this to work, but it shouldn't be that hard.
First you are going to have to open a recordset to get all the emails. Then you are going to have to loop through the recordset. -
-
dim rcd as DAO.recordset
-
dim emailAddress as string
-
-
set rcd = CurrentDB.OpenRecordset("SELECT EmailAddress FROM SomeTable")
-
-
do until rcd.eof
-
emailAddress = emailAddress & rcd!EmailAddress & "; "
-
loop
-
-
'Make sure we have some email addresses
-
if(Len(emailAddress) > 0 )
-
-
'Do something interesting
-
-
Else
-
-
'Report to user no email addresses
-
-
End if
-
This should get you started.
Does t-sql work in access? I'v seen this done with an elaborate use of coalesce and stuff, though I've seen, I could not tell how to repeat.
Lysander 344
Recognized Expert Contributor
Interested in the question. Fairly easy to do in code but can it not be done via PIVOT or TRANSFORM? I can't work out how, but it seems like it should be possible.
T-SQL doesn't work with access (I really wish it would). Also on my list would be stored procedures, but none the less.
I suppose you could do a combination of a VBA function inside the SQL.
I thank you all for the replies.
Sadly, I still cannot seem to make this work.
I'll keep plugging along - it's gotta break eventually for me, right?
I really would need it spelled out for me, I suppose - I wasn't sure what to do with the code above from hype261. Sorry to be dense! If someone has the time to hold me hand through this, fantastic - if you don't, that's fine as well.
The query name I need the info from is "qryRespCount2" and the field is "ResponsibleEmail"
I launch a form that runs 2 queries (qryRespCount1 and qryRespCount2) These in turn give me a list of names (responsible parties that have yet to sign off on jobs) and the count of open jobs per person - that display on a continuous form. My goal was to have a command button at the bottom of that form that would open an Outlook email (or better yet, an Outlook Template) and populate the "To:" field on that email with all of the addresses of the people with delinquent jobs.
Again, if someone has the time to spell it out, I thank you in advance. If not, thank you for your help up until now!
Dave
NeoPa 32,557
Recognized Expert Moderator MVP
Dave, I will see what I can do to help you through this. No promises at this time though. - What's the name of the form you want this data to display on?
- What is the SQL of the recordsource of this form?
- What is the name of the control on the form where you would like the list to display?
Okay - I was off on my Query/Form names slightly...
They are: ResponsibleCountQuery1 and ResponsibleCountQuery2 (I know - this was BEFORE I read about normalization)
The field name is still [ResponsibleEmail]
1. Form name to display data: ResponsibleCountForm1
2. Here's the SQL for the recordset:
SELECT ResponsibleCountQuery2.Responsible, ResponsibleCountQuery2.CountOfResponsible, ResponsibleCountQuery2.ResponsibleEmail, ResponsibleCountQuery2.RoundDate
FROM ResponsibleCountQuery2;
This is a continuous form - the text box I want to write to is in the Form Footer. (again, if this is not a good plan, let me know!)
3. Text24 (on ResponsibleCountForm1 - in the footer)
I would like the values displayed (I guess) in a text box on the very same form - ultimately I want to use SendObject - or better yet, plug it into the "To:" line on an outlook template... SendObject is UGLY when it sends out.
There has to be a better way, right?
The queries take the responsible people, and give me a count of who still has how many jobs delinquent. I then want to generate an email with the click of a button [Command26] to only the people listed them reminding them about it. (yeah - I'm not making friends around here...)
Thanks in advance
Dave
NeoPa 32,557
Recognized Expert Moderator MVP
Well, this is somewhat different from what I expected, but you have answered the questions clearly so let's see where we can go with it. I'm no longer of the opinion that my previous idea will help you much.
As an alternative, it seems we would probably be looking at deciding on a trigger, and developing some code to determine the value when triggered.
There are many Form based events to choose from, but my best guess would be the Load event would suit you best for this.
At that point the code could process through the recordset concatenating all the values together separated by "; "s. As there is no need to move through the Recordset on the form itself, the .RecordsetClone property is probably the one to use.
The code below illustrates the kind of routine you're looking for : - Option Compare Database
-
Option Explicit
-
-
Private Sub Form_Load()
-
Dim strList As String
-
-
With Me.RecordsetClone
-
Do While Not .EOF
-
strList = strList & "; " & .ResponsibleEmail
-
Call .MoveNext
-
Loop
-
Me.Text24 = Mid(strList, 3)
-
End With
-
End Sub
This works beautifully! I owe you a pint!
Thank you. Thank you. Thank you!
NeoPa 32,557
Recognized Expert Moderator MVP
I don't mind if I do :-D
You're welcome of course.
Sign in to post your reply or Sign up for a free account.
Similar topics |
by: Stéphane Ninin |
last post by:
Hi all,
This is not the first time I see this way of coding in Python and
I wonder why this is coded this way:
Howto on PyXML
(http://pyxml.sourceforge.net/topics/howto/node14.html)
shows it...
|
by: Mike Dickens |
last post by:
hi,
i'm sure this has come up before but havn't managed to find an answer.
if i have the following xslt
<?xml version="1.0" encoding="ISO-8859-1"?>
<xsl:stylesheet method="xml" version="1.0"...
|
by: Matt |
last post by:
I have 2 questions:
1. strlen returns an unsigned (size_t) quantity. Why is an unsigned
value more approprate than a signed value? Why is unsighned value less
appropriate?
2. Would there...
|
by: Atara |
last post by:
In my apllication I use the following code:
'-- My Code:
Public Shared Function strDate2Date(ByVal strDate As String) As
System.DateTime
Dim isOk As Boolean = False
If (strDate Is Nothing)...
|
by: campbellbrian2001 |
last post by:
Thanks in Advance! ... I have two textboxes: 1 is visible (and gets its
value based on the invisible textbox and displays either "Male" or
"Female", and needs to display either male of female based...
| |
by: MLH |
last post by:
If I run ?", ",""
in the immediate window,
I get a comma followed by 13 spaces.
It is difficult for me to understand this.
|
by: Denis Petronenko |
last post by:
Hello,
how can i read into strings from ifstream?
file contains values in following format:
value11; val ue12; value 13;
valu e21;value22; value23;
etc.
i need to read like file >string,...
|
by: comp.lang.tcl |
last post by:
set php {<? print_r("Hello World"); ?>}
puts $php; # PRINTS OUT <? print_r("Hello World"); ?>
puts
When I try this within TCL I get the following error:
|
by: manchin2 |
last post by:
Hi,
Can anybody please provide the information about """ and its use, if possible please provide an example.
...
|
by: fran7 |
last post by:
Hi, from help in the javascript forum I found the error in some code but need help. This bit of code works perfectly, trouble is I am writing it to a javascript function so the height needs to be in...
|
by: Oralloy |
last post by:
Hello folks,
I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>".
The problem is that using the GNU compilers,...
| |
by: jinu1996 |
last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
|
by: tracyyun |
last post by:
Dear forum friends,
With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
|
by: agi2029 |
last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
|
by: isladogs |
last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM).
In this session, we are pleased to welcome a new...
|
by: conductexam |
last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...
|
by: adsilva |
last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
| |
by: muto222 |
last post by:
How can i add a mobile payment intergratation into php mysql website.
|
by: bsmnconsultancy |
last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence...
| |