473,396 Members | 1,816 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,396 software developers and data experts.

Code to pull results of one field with multiple answers

93
I have a query I am using to create an email. I have a situation where for one location I have three people that have to receive the information. In the query it creates three records however in my code it only recognizes the first person and does not pick up the other two. How can I get either the code or the query to combine that field for all three records.
Sep 11 '08 #1
8 2473
NeoPa
32,556 Expert Mod 16PB
As we have no idea what your query says OR what your code says - how can we possibly answer that.

Please give some consideration to your question before posting. It can save so much time.
Sep 11 '08 #2
clloyd
93
My code is not the problem. I pulls the field in just fine. It is as follows:

Expand|Select|Wrap|Line Numbers
  1.  Me![email] _
  2.  
My problem is in the query. I have three records as a result of my request thus three contacts that need to pull in my email from the email field. Because they are seperate records it will only pull in the first one it finds and not the other two.

Does this explanation help?
Sep 15 '08 #3
NeoPa
32,556 Expert Mod 16PB
No code (an isolated reference to a single object is NOT code), no SQL, no context, no table information.

Did you really think that would help? I find it hard to credit.
Sep 15 '08 #4
Krandor
50
If you have 3 records then you will need to send out 3 emails. You go through the recordset with a loop until you get to the last record. For each new record, you process the email sending code.

And as Neo said, actually posting either the query or the processing code is going to make your life easier and get a much quicker response.
Sep 16 '08 #5
clloyd
93
I am sorry to have upset you however consider that I am still new at this.

I don't know if this will help or not. I understand I need some type of looping but just can't figure out how to get there.

My tables are as follows: One (Contacts) holds the contact persons information the other table is linked by the Contacts ID and Location number which identifies what location they are responsible for. One location can have three contact people.

Here is my code:
Expand|Select|Wrap|Line Numbers
  1. Private Sub EmailReport_Click()
  2. On Error GoTo Err_EmailReport_Click
  3.  
  4.     Dim Loc_No As String
  5.     Dim stLinkCriteria As String
  6.  
  7.  
  8.     stEmailTo = DLookup("[MailingsEMail]", "[Facilities]", "[Loc No] = '" & Me![Loc No] & "'")
  9.     stLinkCriteria = "[Loc No]=" & "'" & ("[Loc No]=Query![qselReportDistForm]![Loc No]") & "'"
  10.     DoCmd.SendObject acSendNoObject, stDocName, , stEmailTo, ReportMailingCC, , _
  11.     Me![MailingEmailTextSubjectLine] & "," & " " & DLookup("[Client Name]", "[Facilities]", "[Loc No] = '" & Me![Loc No] & "'") & "," & " " & DLookup("[Physical City]", "[Facilities]", "[Loc No] = '" & Me![Loc No] & "'") & "," & " " & DLookup("[Physical State]", "[Facilities]", "[Loc No] = '" & Me![Loc No] & "'") & "," & " " & DLookup("[Physical Country]", "[Facilities]", "[Loc No] = '" & Me![Loc No] & "'") & " " & "Loc No" & " " & Me![Loc No], _
  12. "The following Facility Specific Copies personel listed needs to be moved to the CC" & " " & Me![email] _
  13.     & vbCr & "  " _
  14.     & vbCr & "  " _
  15.     & vbCr & Me![MailingEmailText]
  16.  
  17.  
  18. Exit_EmailReport_Click:
  19.     Exit Sub
  20.  
  21. Err_EmailReport_Click:
  22.     MsgBox Err.Description
  23.     Resume Exit_EmailReport_Click
  24.     DoCmd.Close
  25.  
  26. End Sub
The Me![email] field is the one that can have multiple records for one location.
Sep 18 '08 #6
NeoPa
32,556 Expert Mod 16PB
If Me.Email can possibly have multiple records, then surely we have a logic problem. I'm having to read between the lines somewhat, but I suspect the form will only show one of these at a time. That makes life a little more complicated. We either need to design things such that a ";" separated string is available on the form, or we could possibly look at opening a DAO.Recordset in the code to access each in turn within the routine.

Have a look at Basic DAO recordset loop using two recordsets for some basic use of Recordset coding. We can get into more detail if and when required, but this may point you in the right direction.
Sep 19 '08 #7
clloyd
93
Thank you I will and get back to you. I may not have explained this very well and apologise for that. I have to have two tables one is the Location and a location can have multiple safety people assigned that have their own table with their personal information. In sending an email for a location I have to pull in multiple safety people. You are correct in that it will only pull in the first one it sees. As I mentioned I will review this informtion you provided and let you know. Thanks
Sep 19 '08 #8
NeoPa
32,556 Expert Mod 16PB
No worries. Take your time.

When you better understand which way you want to go forward we can cover it in more detail :)
Sep 19 '08 #9

Sign in to post your reply or Sign up for a free account.

Similar topics

3
by: Mohammed Mazid | last post by:
Hi folks! Can anyone please help me with this? I am developing a Quiz program but I am stuck with "multiple answers". Basically I need some sort of code that would select multiple answers...
4
by: Mohammed Mazid | last post by:
Hi folks! Can anyone please help me with this? I am developing a Quiz program but I am stuck with "multiple answers". Basically I need some sort of code that would select multiple answers...
7
by: Rick Caborn | last post by:
Does anyone know of a way to execute sql code from a dynamically built text field? Before beginning, let me state that I know this db architecture is built solely for frustration and I hope to...
5
by: Julia Baresch | last post by:
Hi everyone, I haven't found any reference to this problem on this group or in Access 97 help. I hope someone here knows this - probably a simple thing, but not obvious. I designed a query to...
3
by: Iain Miller | last post by:
Can anybody help me with some Access 2000 code? I don't do a lot of coding in Access & so every time I come back to do something I pretty much have to relearn the syntax from scratch so this is...
143
by: suri | last post by:
Hello I downloaded glibc and tried looking for the code that implements the sine function i couldnt find the file. i went to the math directory and found math.h.. i guess that needs to be...
12
by: chadlupkes | last post by:
I've been trying to create a simple (I hope) PHP application to send emails to a membership list. I have yet to successfully connect to my database to pull the names and email addresses. I'm...
232
by: robert maas, see http://tinyurl.com/uh3t | last post by:
I'm working on examples of programming in several languages, all (except PHP) running under CGI so that I can show both the source files and the actually running of the examples online. The first...
10
hyperpau
by: hyperpau | last post by:
I've been going nuts about it and I've been searching all over the forums to find answers. Can somebody please help me? I am a somehow advanced Access user with basic VBA knowledge. (No ADO or...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
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,...
0
jinu1996
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...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
agi2029
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 using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.