Modules & VBA :: Emailing Table Results

Jan 10, 2014

I would like to have my macro/vba send an email based on the results of two tables, or if both tables are null, i'd like the email to state that.

View Replies


ADVERTISEMENT

Modules & VBA :: Emailing From Within Access?

Aug 29, 2014

I am trying to automate the process of sending a query result via email.

I have code that will export a query as an excel document, using DoCmd.SendObject, but it has the name of the query.

DoCmd.SendObject acSendQuery, "Dailyrpt", acFormatXLSX, email.address, , , "Daily Report", "This is today's report", -1, False (email.address would actually be the email address it is being sent to.)

I also have code that will export the query to excel and save it as a file, using DoCmd.OutputTo, where I was able to name it something meaningful to the end user, and include the date.

DoCmd.OutputTo acOutputQuery, "Dailyrpt", acFormatXLSX, "Z:FolderComplete as of " & Format(Date, "yyyymmdd") & ".xlsx"
Dim Foldername As String
Foldername = "Z:FolderComplete as of " & Format(Date, "yyyymmdd") & ".xlsx"
Shell "C:Program Files (x86)Microsoft OfficeOffice14EXCEL.exe """ & Foldername & "", vbNormalFocus

Is there a way to either send the saved (renamed) file or to include the current date as part of the SendObject command?

View 4 Replies View Related

Modules & VBA :: Emailing From The Database?

Oct 22, 2014

I have a database with my staff in. If they are car drivers I take not of their Insurance and MOT renewal dates. I have built a query that gives me a reminder date ten days before and 5 days after the renewal. I also have an email function that emails my administrators the dates of these. Is there a way of getting the database to email specifically on those dates. I.e. a reminder 10 days before and a check 5 days after?

View 3 Replies View Related

Modules & VBA :: Exporting And Emailing From Access

Jul 18, 2013

i am very new to access, but i can code in excel well.what i really want to do is no how to automatically email a report, query or table. I also would like to be able to export the above three to excel as well. I have worked my way up a little bit but my hair is falling out with how hard this is to achieve. I have come up with the following so far:

Code:

Dim outputFileName As String
Dim oXL As Object
Dim oExcel As Object
Dim sFullPath As String
Dim sPath As String

[code]...

The above code works a bit, but it only allows me to export tables (dont know how to modify it). It also doesnt open the table in excel properly, it opens excel, but the table doesnt open. I have to go to the location and manually open it.

View 6 Replies View Related

Modules & VBA :: Why Does Emailing A PDF Work But Saving A PDF Doesn't

Jul 24, 2013

I'm trying to figure out why I can email a report as a PDF, but not save it as a PDF using the code below? When I save, I get the dreaded error 2501.

The searching I did for this said to uninstall and reinstall printers (I've done that - seems to have no effect), or took issue with filtering the report with a where clause (but if that was an issue, why does it email a PDF just fine?).I'd just like to be able to save a report as a PDF to a specified location.

CB
Developing in: Access 2010; Win7
For use in a mixed 2007/2010 XP/7 environment

Code:

Private Sub EmailDietCardBtn_Click()
On Error GoTo MyErrorHandler
Me.Refresh
Dim stReport As String
Dim stWhere As String
Dim stSubject As String
Dim stEmailMessage As String
Dim stCaption As String
Dim myPath As String

[code]...

View 11 Replies View Related

Modules & VBA :: Adding Password To A Document Before Emailing

Jul 2, 2015

I have built a simple database (by no means complete) but I am after adding some further code into it. Basically on the form [FrmMain] I have a button that allows me to send a document to a relevant CSU contact. It finds the file name based on the info in the table TblResident. What I want to do is open the word document before sending and add a password to it using vba.

View 1 Replies View Related

Modules & VBA :: Word Naming And Emailing Attach From Access 10?

Apr 21, 2015

I need to create a word file (it needs to be word) based on template (not a very complicated template) max 1 to 1 and 1/2 pages long.

the word doc needs to be named from the recordset but for now assume 12345.doc and the next one will be 12346.doc etc (I have a unique number system - available from tables /query .

i can either make the word doc in code or use a template (template would be better) recordset could have 20-30 in it each time i run it - but to be run every week

second half is how to email this out. i had in mind a email system

email to . test@testhotmail.xyz
file attach = this folder where the docs are store and attach 12345

in a loop

so either

create word file - email word file in a loop each time or create all the word files and then send them individual

View 4 Replies View Related

Modules & VBA :: Accounts Package - Emailing Reports As PDFs

Jul 19, 2013

I've created an accounts package for my business using access 2003 and I'm just thinking of some time saving features.

We need to email our invoices to our clients.

Normally we print out an invoice, scan it back into the computer, save as a PDF and attach to an email manually one by one.

My package can now print to PDF (saving one step), but what I would like is to be able to print to PDF and attach to a new email (with the email address coming from the customer table) and possibly attach more than one PDF to a single email.

I know you can use

Code:
DoCmd.SendObject acReport, stDocName

to send a report but I would like it as a PDF as my formatiing is lost using that code and we normally send PDFs to our clients.

View 14 Replies View Related

Modules & VBA :: ADO With SQL To Add Append Query Results To Excel 2007 Table

Oct 16, 2014

I have successfully used VBA to populate select query results into an excel worksheet on open, for a co-worker. Now I am trying to populate the records from an append query to the bottom of those results, which are now in a table on an excel spreadsheet, Contractor EIF. I am trying to make this work because my co-worker modifies the results in the table, deleting rows, adding fill color etc. and as new projects begin he would like those added to the projects already in the table (without rewriting the entire table).

Private Sub Window_Open()
Dim strDB As String
Dim strMyPath As String
Dim strDBName As String

[code]....

View 2 Replies View Related

Modules & VBA :: Send Query Results In Table In Body Of Email

May 24, 2014

I have created some code to get the records of a query and it puts them in the body of the email but it doesn't format it well for example the email looks like

James | halliwell | 31
Leanne | smith |27
Alexis | smith |8

I would like it to be in a table is this possible,

Code:
Public Function SendEmail()
Dim MyDB As DAO.Database
Dim rst As DAO.Recordset
Set MyDB = CurrentDb

[Code] .....

View 3 Replies View Related

Modules & VBA :: Using Check Box On A Form To Filter Out Results From A Table That Is Checked

May 23, 2014

I have kept the names as simple as I can for the example sake to which I can substitute my names in after.

I have a split form - form1, I have a check box on this form - checkbox1 - That I would like to use to make only the checked results from the table - table1 - show and if it is not checked to show all the results. How would I go about doing this? The table field is called field1.

View 6 Replies View Related

Emailing Customers With Data From A Table

May 24, 2012

I have a table with all of the relevant data.

I want to automate an email to each one with the information that is held in the table. Much like a mail merge.

The email would be in one field.T
The subject would be: "Your item[ Item Name] has been shipped."
The body of the email would be: "Thanks for buying [product] on [date of purchase] etc etc."

My only problem is that I'm shit at code so I wanted to know if I could do it with Macros.

I could do it through a combination of using max records: sending an email, then repeating the exercise until all of my records have been sent.

View 1 Replies View Related

Emailing A Table Increases File Size

Apr 4, 2006

Hi,

I am trying to send a "EMP" table in an excel format using "SendObject". User clicks the "Send Mail" button to email the table in excel file. The user then clicks on the "Exit" button to exit. This wipes out the data in the table "EMP" as was expected. Every thing goes fine..... but the size of my database increases by more than 100 MB. (Note that the table in the data has been deleted & the data is around 59 MB).

Any suggestions on what could be causing this increase in file size.

Thx in advance,

Jatz

View 5 Replies View Related

General :: Stepping Through A Table Row By Row - Emailing A Report

Mar 23, 2015

I have a table, each row contains information that I want email out as a pdf.

I've created a report, and at the moment I've created a button embedded with the onscreen report which emails the report I'm actually looking at onscreen (as an attachment), all the button is doing is event-on click running this VBA code...

Code:
DoCmd.SendObject acSendReport, "rptSalesReceiptMain_UK", acFormatPDF, DLookup("[Email]", "[Sales]", "[PrintInvoice]=True"), , , "VAT Receipt for your order", "As requested, please find your VAT sales receipt attached"

...it all works, but it's very manual....because I have to open up each report manually, & then click the button manually to create the email

Since I have the main 'chunky' parts done (i.e. creating the report & the code that emails it when I click a button), I'm now turning my attention to automating.

I'd like to add a new true/false column to my table "Receipt Emailed" (or similar) & have a bit of VBA hunt down the column, then it comes across a false condition, it runs the report & emails it.

Therefore rather than me opening the report & clicking on the button (which runs vba code), how do I get this done automatically?

View 2 Replies View Related

Modules & VBA :: Results For Last 14 Days

Feb 27, 2014

I'd like to get results for last x days

I'm trying to use this, but it doesn't filter the results

Code:
DoCmd.OpenForm "Overview", , , "oDate" > (Date - 14)

or more specifically

Code:
DoCmd.OpenForm "Overview", , , "oOdd = '" & Me.cmbodd & "' and oDate" > (Date - 14)

i tried plenty of different variations with not much success...

View 3 Replies View Related

Modules & VBA :: DLookup Not Returning Any Results

Mar 26, 2014

Here is my VBA Dlookup Code:

Code:
Public Sub test()
Dim frm As Form
Set frm = Forms!StationLevelSummary

[code]...

At the bottom im printing the content of the controls which are on my form. These should return 1 number, but for some reason it does not. Ive used this code many times but I cant figure out why nothing is being returned.

View 4 Replies View Related

Modules & VBA :: Filtering Results In List Box

Apr 21, 2014

I am using a form in which i am filtering the results in the list box based on the textbox value. I am dynamically switching 3 row sources for the list box.

My Need is that the results produced in the listbox should get filtered again when typing in the second text box i.e based o the country name.

View 1 Replies View Related

Modules & VBA :: Like Function Returning Odd Results

Jan 13, 2014

I'm trying to do a string compare between two variables. One string variable is part of an array (which I'm looping through), the other is passed to the function as an argument.the function should return the position of a field in the OrderBy string of a subform.Here's the VBA :

Code:

Private Function SortPosition(strOrderBy As String, strField As String) As StringDim arrSortedFields() As String
Dim i As Long
If Len(strOrderBy) > 0 And InStr(strOrderBy, strField) > 0 Then
arrSortedFields = Split(strOrderBy, ",")

[code]....

The weird thing is, the line in blue returns True when, by watching the variables, it appears that it should not, and returns False when it appears that it should?

arrSortedFields(i) = "[RandomField]"
strField = "RandomField"
arrSortedFields(i) Like "[" & strField & "]*" = False
arrSortedFields(i) = "[SomeFieldName]"
strField = "ADifferentField"
arrSortedFields(i) Like "[" & strField & "]*" = True

I would have thought the expression "[RandomField]" Like "[RandomField]*" should return True?And similarly the expression "[SomeFieldName]" Like "[ADifferentField]*" should return False?Have been using 'Like' for donkey's years and never seen it throw results like this before?

(P.S. The reason I need to use 'Like' rather than a straight = is to account for the possibility that a field may be sorted descending, and therefore to nullify the DESC keyword which may follow any given field...)

View 9 Replies View Related

Modules & VBA :: Displaying Results Of A Select Statement?

Oct 7, 2014

I have a database with several one-to-many relationships and a nested subform based off of those relationships. Relationships are as follows:

One Lender to Many Relationship IDs
One Relationship ID to Many Tax IDs
One Tax ID to Many DocumentsRequired

My forms are nested as follows:

Relationship ID form (contains info for Relationship ID and Lender)
-> Tax ID
-> DocumentsRequired

I believe I'm just overcomplicating this. But I have simple search box (an unbound text box with a command button), which is located on the top-level form for Relationship IDs. As you'll see above, that form only contains the fields for Relationship ID and Lender. However, users have to be able to search by Relationship ID, Customer Name, or Tax ID number, the last two of which are only available on the nested subforms. Currently I have the search box reaching out to grab results from a query. When I assign the results to the Me.RecordSource, it works perfectly except that it's in read-only format. The users have to be able to edit the results of their search. I'm not even sure I'm doing this in the easiest fashion. I would have preferred to just use the select statement to search through the subform, but I'm guessing my syntax was wrong because I never got it to work. Below is what I currently have.

Dim strtext As String
Dim strsearch As String
strtext = Me.SearchBoxTxt.Value
strsearch = "SELECT [Relationship ID] " & _
"FROM CustomerNormQuery " & _
"WHERE [Relationship ID] like ""*" & strtext & "*"" OR [Customer Name] Like ""*" & strtext & "*"" " & _
"OR [EIN/SSN] Like ""*" & strtext & "*"" " & _
"GROUP BY [Relationship ID]"
Me.RecordSource = strsearch

View 4 Replies View Related

Modules & VBA :: Passing Variables And Retrieving Results?

Jul 9, 2014

I wrote this module

Option Compare Database

Option Explicit

Public Function OdometerInput(varodometer As Variant) As Long
Dim varKilometres As Variant
varKilometres = varodometer * 1.609344
OdometerInput = CLng(varKilometres)
End Function

It works fine in the immediate window (although I haven't just fathomed what to do with null values and such) But my question which I am sure will be 'easy when you know' is how do I pass the variable to it from a text box on a form and retrieve the data in another text box on a form.

View 4 Replies View Related

Modules & VBA :: Goto Record Without Filtering Results

Dec 5, 2013

Is there a way to search for a term within a form and goto a record that matches that term assuming there was only one matching result (Unique ID, for example).

But NOT filter the results so that user can still navigate as usual after the search has been carried out.

View 1 Replies View Related

Modules & VBA :: Populate Combobox From Listbox Results

Jun 12, 2015

I have a list of staff that have a conflict of interest with a particular entity. As a result, these staff are not allowed to interview these entities.

I have a query that matches all staff with their respective entities that they have a conflict of interest with (CoI) and that is functioning correctly.

When the form loads to add an interview, there is a listbox that pulls all the people who are not allowed to do an interview with that particular entity. That is also working correctly.

I have a subform, that is a continuous form, which will allow the user to add staff, one at a time, via a drop down box. These people are stored in their own table with a FK Id to the interview table. This also works correctly.

How to filter the combobox on the subform to exclude the people in the listbox.

Here is what I have tried, loosely based on what I have found on Google and researching here. I am 100% sure it is not working correctly, but what I am missing.

The query the listbox is based on has 3 colums, the ID, the Name, and the business contract number.

Code:
Private Sub Form_Load()
Dim strSource As String
Dim i As Integer
For i = 0 To Me.lstCoI.ListCount - 1

[Code] ....

In the immediate window, I get the following result:

SELECT [staff] FROM lutStaff WHERE Staff <> name1
SELECT [staff] FROM lutStaff WHERE Staff <> name2
SELECT [staff] FROM lutStaff WHERE Staff <> name3
SELECT [staff] FROM lutStaff WHERE Staff <> name4
SELECT [staff] FROM lutStaff WHERE Staff <> name5
SELECT [staff] FROM lutStaff WHERE Staff <> name6

The issue is that the box is not filtering all the names out of the list it is built on. It is only filtering out the last name.

Obviously I need to save the results for comparison, but I am at a loss on how to do that.

View 10 Replies View Related

Modules & VBA :: Storing Query Results In A Variable

Jan 20, 2014

I have a query which returns a list of reports I have created this session.

I want a button that when I click it runs the query and then stores the results into a variable.

I looked online and found a pretty good connection code and loop code to get the data but I'm having a hard time getting it to store into a variable.

What I want to do next is using code print the reports that were listed in the query.

That Means I need to be able to take that variable and pop the information off it, storing it into another variable (or if i can use an array just use that) and use that to concatenate into a command to print that report.

I am having problems with the syntax of this though. I think I'm just missing some key elements.

View 3 Replies View Related

Modules & VBA :: Time Calculations - Inconsistent Results?

Jul 9, 2014

I work for a bank and have build a few little DB's for differant groups but my current project is a work flow tool for a department. I have it 90% completed and i still have to build in the reporting side. Part of the reporting is caclulating times and this is where i am having problem.

I have some coding built but i am getting inconsistant results, as an example if i am trying to calculate the total amount of time between [start Time], [End Time] then minus any [Stop Time].

Code:
Me.Total_Time = Format(Int(Workhours(DateAdd("n", Nz([Total_Stop_Time]), [Processor_Date_Stamp]), [Date_Sent_to_RM])), "00") & ":" & Format(Int((Workhours(DateAdd("n", Nz([Total_Stop_Time]), [Processor_Date_Stamp]), [Date_Sent_to_RM]) * 3600 - (Int(Workhours(DateAdd("n", Nz([Total_Stop_Time]), [Processor_Date_Stamp]), [Date_Sent_to_RM])) * 3600)) / 60), "00") & ":" & Format(((Workhours(DateAdd("n", Nz([Total_Stop_Time]), [Processor_Date_Stamp]), [Date_Sent_to_RM]) * 3600 Mod 60)), "00")

I have this on a command button, i have this same code for a few other calculations and in some cases it seems to be working i have just changed my start and stop fields along with what stop time to take out in each case. I have attached some parts of my DB, one of the modules, my main table and the form where i am running the coding.

View 4 Replies View Related

Modules & VBA :: How To Create And See Results Of SELECT Query

Mar 22, 2015

I was beginning to think I had got the hang of creating queries on the fly in VBA. After several hours I have just learned that docmd.runSQL does not work for simple SELECT statements. I'm not going to worry about why that would be. I'm sure there's a jolly good reason.

So... I am able to dynamically create the SQL string for the SELECT statement that I need.

How do I run it? It just needs to return results as a datasheet so I can see them. I'm running Access 2013. I've been searching on this subject for quite a while and found many references to DAO, ADO, ADODAOD, YODELAEYYOUDELAYIO! and other things I don't yet understand ...

View 8 Replies View Related

Modules & VBA :: 2nd Run Of A Function Calculates Wrong Results?

Jul 21, 2014

i am using the following function in a query:

Code:
Public Function Progress(ByVal varCompany As Variant _
, ByVal varPercent As Variant) As Variant
Static varCompanyOld As Variant
Static varValueOld As Variant
Dim Value As Variant
If varCompany & vbNullChar = varCompanyOld Then
Value = (1 + varPercent) * varValueOld
varValueOld = Value

[code]....

This function is working if I use it with two or more companies.If I have only one company, it works at the first (query) run, too.But with the same company, a second (query) run calculates different results.

I think it is because of this condition:

Code:
If varCompany & vbNullChar = varCompanyOld Then ...

If the company name is e.g. Microsoft

At the first run of the query:

Microsoft & vbNullChar = "" -> wrong

The Else calculation will be carried out.

-> That is right for the first datapoint of a company

At a second run of the query:

varCompanyOld is saved as Microsoft & vbNullChar, so:

Microsoft & vbNullChar = Microsoft & vbNullChar -> True

The main calculation will be carried out.

-> That is wrong for the first datapoint of a company

View 14 Replies View Related







Copyrights 2005-15 www.BigResource.com, All rights reserved