473,385 Members | 2,014 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,385 software developers and data experts.

how to code for ms access vba to create the report one at a time for each record

Here is what I am trying to do - i have a report in MS access called "DocProcurement". it is based off of a query. the query can have many records in it. the report shows all records from the query. i want to open the report one record at a time from the query (based on email address), save it, and send the report in email. The report should only have the info from one record in the query, then move on to the next record, create it and send it out, etc... Here is what i have:

Expand|Select|Wrap|Line Numbers
  1. Sub CreateEachEmail()
  2.  
  3. Dim Rst As ADODB.Recordset
  4. Dim FaxNumber As String
  5. Dim PhoneNumber As String
  6. Dim SendFaxTo As String
  7. Dim x As Integer
  8. Dim Msg As String
  9. Dim numToEmail As Integer
  10. Dim UserName As String
  11. Dim blnClosed As Boolean
  12. Dim address As String
  13. Dim Atest As ClassEmailFunctions
  14. Dim strEmail As String
  15.  
  16.  
  17. x = 0
  18.  
  19. Set Rst = New ADODB.Recordset
  20. With Rst
  21.     .Open "qryFaxList", cnn, adOpenStatic
  22.     .MoveFirst
  23.         While Not (.EOF Or x = numToEmail)
  24.  
  25.  
  26.              Do Until x = numToEmail Or .EOF
  27.                 FaxNumber = Rst![CAFax]
  28.                 PhoneNumber = Rst![CAPhone]
  29.                 SendFaxTo = Nz(Rst![CAName], "CLOSING AGENT")
  30.                 address = Rst![CAEmail]
  31.  
  32.  
  33.                 If Rst![NumberOfDocs] < 1000 Then
  34.  
  35.                 Else
  36.                     GoTo RS_MoveNext
  37.                 End If
  38.  
  39.  
  40.             strEmail = address
  41.  
  42.             Set Atest = New ClassEmailFunctions
  43.  
  44.          Atest.ToAdd (strEmail)
  45.          Atest.Subject = "IMPORTANT DOCUMENTS REQUIRED"
  46.          Atest.Body = "PLEASE SEE ATTACHED REPORT FOR DOCUMENTS REQUIRED"
  47.  
  48.          DoCmd.OpenReport "DocProcurement", acViewPreview, "", , acNormal
  49.          DoCmd.Close acReport, "DocProcurement"
  50.          DoCmd.OutputTo acReport, "DocProcurement", "RichTextFormat(*.rtf)", "C:\Temp\DocProcurement.rtf", False, "", 0
  51.  
  52.          Atest.Attachment = ("C:\Temp\DocProcurement.rtf")
  53.  
  54.          Atest.Send
  55.  
  56.        RS_MoveNext:
  57.  
  58.                 .MoveNext
  59.                ' x = x + 1
  60.             Loop
  61.  
  62.  
  63.         .Close
  64.     End With
Sep 8 '10 #1
0 934

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

Similar topics

4
by: Joe User | last post by:
Hi all....I have a feeling this is going to be one of those twisted query questions, but here it goes anyways.... I want to generate a report that shows the chronology of events (represented by...
1
by: Justin Koivisto | last post by:
I am trying to create a report that displays a name of an advertising source and count of the number of times it was hit between certain date ranges. The data is split between two different...
20
by: Greg | last post by:
I'm fairly new to access (using 2002) and am setting up a DB for work. along with each record the user also needs to make a flow diagram (previously, these reports were composed in word and they...
0
by: ghadley_00 | last post by:
MS Access Create form / report with multiple pages using different background images Hi, Would like to have users fill out a multipage form, and then click a print button, which pulls up the...
9
by: MLH | last post by:
I have a source query (qryITSLetterList) feeding rows containing name, addr, city, state, zip and VehicleID to a report (rptITSnotices). The query may contain 1-to-5 records resulting in 1-to-5...
3
by: kevinj | last post by:
Greetings, I am creating a "stoplight" type report that is based on the number of days between dates, the field will be highlighted in red, yellow, or green. I am able to change the background...
1
by: seawolf | last post by:
Is there a way to create a numbering for the Details in an Access 2003 Report. For instance, if a report has 12 records that make up the Details in a report, can these be numbered, i.e., 1, 2, 3, 4,...
7
by: KiwiGenie | last post by:
I have a form which lists selected records, there could be anything from 1 record to all records selected. I want to output a report for each record as HTML. I want each file to take its name from a...
0
by: maxx429 | last post by:
Hi all, I am posting this question for a co-worker. She knows very little about Access but has been asked to create some reports. One the requirements is that the report contain a Pie Chart...
0
by: cowboyjunkey | last post by:
This is what I want to do: Each report page will list some details about a sample (like time sampled, where, who sampled) and below it a chart showing the distribution of the sample (i.e....
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
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: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
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...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
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
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,...
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...

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.