473,769 Members | 2,402 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Access / Mail Merge

1 New Member
I'm trying to create an e-mail statement that pulls data from two tables....one table is simply the Student information (e-mail, name, phone etc) and the other table is a Transaction table that can have multiple rows per student.

Using Word mail merge I'm able to send a single e-mail to each entry in the Student table, however in the body of the e-mail I'd like to include the Student's transactions. Students - Transactions is a one to many relationship. I cannot seem to find a way to add the Student's Transaction information to the e-mail.

Side note...does anyone know where I can simply purchase a MS Access solution to manage scrip transactions (http://www.glscrip.com)?

[email removed]
Mar 15 '07 #1
1 1984
nico5038
3,080 Recognized Expert Specialist
This is best handled by sending the email from VBA and by constructing the message body from code with a recordset processing loop like in the following code.

Expand|Select|Wrap|Line Numbers
  1. Private Sub btnMail_Click()
  2.  
  3. Dim rs As Recordset
  4. Dim strBody As String
  5.  
  6. ' Get the tansaction data
  7. Set rs = CurrentDb.OpenRecordset("tblTransactions")
  8. If rs.EOF And rs.BOF Then
  9.    MsgBox "No data for email"
  10.    GoTo exit_btnMail_Click
  11. End If
  12.  
  13. strBody = "Dear sir, " & vbCRLF & vbCRLF
  14. strBody = strBody & "We found the following transactions: " 
  15.  
  16. rs.MoveFirst
  17. ' loop to fill Body text
  18. While Not rs.EOF
  19.    strBody = strBody & vbCRLF & rs!YourField   
  20.    rs.MoveNext
  21. Wend
  22. strBody = strBody & vbCRLF & "Sincerely," 
  23. strBody = strBody & vbCRLF & "The email team" 
  24.  
  25. ' Send the Object
  26. ' The fields strTo, strCC, strBCC and strSubject correspond to the string you have to fill yourself
  27. ' e.g. by using for strTo: Me.StudentEmail
  28. ' when the emailaddress is on the form.
  29. ' or hardcoded: "emailname@home.com"
  30.  
  31. DoCmd.SendObject acSendNoObject, , , strTo, strCC, strBCC, strSubject, strBody
  32.  
  33. exit_btnMail_Click:
  34. End Sub
  35.  
Nic;o)
Mar 17 '07 #2

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

Similar topics

6
3711
by: Ecohouse | last post by:
I have a computer with XP on it. I loaded Office 97 first because I needed Access 97 for some work. I then loaded Office 2000. Everything seemed to be running fine. But I have come across a few problems. 1) I have hyperlinks in some tables and when I try to access the hyperlinks I get an error message "An unexpected error has occurred. 2) I've been trying to do some automation through Access for MS Word using VBA code. I've been...
9
4324
by: Neil Ginsberg | last post by:
I have a strange situation using Access to automate a Word mail merge. Using Access 2000 and Word 2000, the code opens Word, opens the document in Word, sets a table in the calling Access application as the data source, and then performs a merge. Everything works fine. However, when a user uses it in Access 2002 and Word 2002, an extra instance of the Access application is opened and remains open at the end. Sometimes it remains open
3
2366
by: Strasser | last post by:
In Access2000 mass emailing worked perfectly (very powerful tool!). Doesn't work when using XP version of both Access and Outlook, even though I checked the box to ensure that I was sending the email. Any ideas? Thanks in advance.
3
5587
by: Andy Davis | last post by:
I have set up a mail merge document in Word 2003 which gets its data from my Access 2000 database. I want to set up a button on a form that: 1. runs the query to provide the dat for the merge document in Word; 2. opens the document and runs the merge process for the new data. I have managed to write the code to perform step 1 ok, but I'm having trouble with step 2. It opens the word document fine but does not perform the mail merge of...
4
7475
by: pmhaupt2 | last post by:
I developed an Access 2003 program that will allow the user to produce a group of Word letters that merge with data records from an Access database. I created a mail merge Word document and associated it with a specific query in my Access database. My problem is that when I run my "create letters" button from an Access form, the program opens up Word correctly with the proper letter. However, the MailMerge toolbar in Word appears...
8
13336
by: Ron B | last post by:
Help!!! What am I doing wrong? I am working with Office 2003 and am trying to create a command button on an Access form that will create a mail merge in Word from an Access table. I want to make the mail merge seamless to the user so all they have to do is click on the command button and the letters are generated. For the button I created an event procedure with the following code: Private Sub RunLetters_Click()
6
4649
by: crealesmith | last post by:
Firstly, I have no problem with mail merging to Word, VB code for that works perfectly. On one mail merge I need to merge 15 fields of data that are from 3 seperate records. The 3 records are all in the same table. If I use a control source that is selecting the 3 records, all of the data is shown but spread over 3 pages in the mail merge, but needs to be listed together in one paragraph. Is there anyway of looping through the 3...
1
6546
by: Esther Lane | last post by:
Hello! First off, many many thanks to Albert who wrote the Mail Merge code for MS Access I am using. It has been working beautifully for a few years. However, my client just (without notice!) upgraded from Access 2000 to Access 2007. Now that component is failing. The merge is building the data source file fine (text file named merge.888). I am providing an absolute path reference to the word file being used for the mail merge. ...
1
5061
by: kayberrie | last post by:
I want to write a VBA mail merge code. I want to link the code/macro/dohicky to a nifty little button so it makes life easy. I think I can handle the button part, the code part - not so much. I know very little (actually probably nothing) about VBA and I'm currently learning my way around Access. Basically, I want to click a button in the form that merges the letter for me, only for the one record I'm currently viewing..not the whole...
3
2827
tdw
by: tdw | last post by:
Hi all, I am trying to create an Access database for use purely as a more efficient way to enter fields into a Mail Merge for a friend who is an attorney. Currently, I am using Word's mail merge, but the problem with that is that it is time consuming and inefficient because there is no way to set it up to recognize commonly used entries and autofill the field. The first paragraph of the form letters look something like this (the parts...
0
9586
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
9423
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
10210
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
10043
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
9990
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 Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
9861
tracyyun
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 protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
1
7406
isladogs
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 presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
5298
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
2
3561
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

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.