Tracking Forums, Newsgroups, Maling Lists
Home Scripts Tutorials Tracker Forums
  HOME    TRACKER    Visual Basic

VBA DoCmd.SendObject Problem

I know this is a long shot..
im creating a new Lotus Notes 5 mail memo via DoCmd.SendObject.
Everything works fine but it will not populate the "To" or "CC" field of the email like it is supposed to.. Cant figure out why.

here is the DoCmd code
DoCmd.SendObject acSendNoObject, , acFormatTXT, toname, ccname, , Forms![Team Leads QA Form]![Ticket], msgBody, True

the DoCmd.SendObject Format:

DoCmd.SendObject [objecttype][, objectname][, outputformat][, to][, cc][, bcc][, subject][, messagetext][, editmessage][, templatefile]

thanks for any help

View Complete Forum Thread with Replies

See Related Forum Messages: Follow the Links Below to View Complete Thread
I need to send a query that is based on results given in my code:

DoCmd.SendObject acQuery, rs, acFormatHTML, rs![nmc email address], , , eSub, eText, False

where Set rs = CurrentDb.OpenRecordset(strSQL) was defined previously

I get a an expression you entered is the wrong data

DoCmd.SendObject - Way Over My Head!

I want to send out emails with attachments. I currently have a list of email addresses in Col A of an Excel Spreadsheet and file names (to be attached) in Col B. I can't send an attachment through Excel with a subject line and therefore need to do it through Access. Unfortunately, all the objects and commands in Access are different. If I import the .xls of addresses and files into an Access table, I know it can be done as there are references to it all over the net. We run Groupwise 5.5 so I can't do it thru Outlook. (Groupwise is MAPI compliant though)

Please could someone post some code to help, I am getting desperate!!

Problems With DoCmd.SendObject
Hello Everybody,

I am using DoCmd.SendObject method to send an email with a .html attachment to it .

Everything works fine except for the .html file format . I want to change the default format which it comes up with . If anybody has any ideas or changes please reply me asap.

Thank You

Reference To Field In DoCmd.SendObject
This (hopefully) is the most simple question to have appeared on this forum, but being new to VB, it has me stumped.

In MS Access 97, I am trying to reference the field Start_Date from the table tblBounds in a VBA module. I have this so far:

Function mcrSend()
On Error GoTo mcrSend_Err

DoCmd.SendObject acQuery, "Query_Name", "MicrosoftExcel(*.xls)", "", "", "", "subject " & ????, "e-mail body", False, ""

Exit Function

MsgBox Error$
Resume mcrSend_Exit

End Function

Where the ???? is, I would like to have it include the Start_Date from the table tblBounds. What this does is place the date of the data being sent into the subject line of the e-mail it creates. I can replace ???? with DateValue(Now()), but the date is not always today. Again, I hope it's fairly simple to pull the value from the Access table.

Thank you in advance for the information.

DoCmd.SendObject - Inconsistent Behavior?
I have a form with a list of contacts a user can select and then click on a button. This will trigger the execution of a report,
send it, and close it.

For some reason, the behavior of the program is inconsistent and I can't figure out what's causing the inconsistency.

The first time a box will usually pop up that asks to choose a profile .... the current profile is correct, so I continue by hitting ok, then the report is sent with the email....

The next time I click to send another report via email, nothing happens??? If I completely shut out of Access and repeat the same steps, the same behavior occurs .....

Would anyone, have any insight into this???

Below is the code:

DoCmd.OpenReport stDocName, acPreview, , strwhere_Title

DoCmd.SendObject acSendReport, stDocName, acFormatRTF, email_address, , , "Testing", "This is really a test", 0

DoCmd.Close acReport, stDocName

DoCmd.SendObject Email Addres From A Field/table
I am trying to automate Email reports from Access, the macro uses a predefined email address and
cannot be changed depending on a report or query.

Is there a way of sending a report using addresses in a table or query?

Are there any examples on the web? What about some VBA example code?

Will DoCmd.SendObject Work Fine In Access 2k Integrating With Lotus Notes 5.0.5 Mailing

There is an existing application in access 97 using the following object to send a mail with the report as an attacment.

DoCmd.SendObject [objecttype][, objectname][, outputformat][, to][, cc][, bcc][, subject][, messagetext][, editmessage][, templatefile]

here lotus notes 5.0.5 server verson i used for mailing..

After upgarding the existing application to access 2k. the same piece of code is unable to send mail.

My question is... will the same line of code is compatible for sending mails through lotus notes 5.0.5.

if no what is the process...

waiting for ur valuable suggestions


I have an AccessDB that uses the SendObject command to send an e-mail from one user to another. I have one user that repeatedly gets the following messagebox:

"Location Document form Profile cannont be found"

Does anyone know what this means. The Windows Messaging Profile is setup correctly. Additionally this mechanism is working perfectly on 40+ other computers. I cannot find any obvious differences between this computer and all of the others.

I am just using VBA in MS Access to send an email when a button is pressed. I am using the SendObject command. Everything works fine but I just am not sure how to get the body of the email (message text) to reflect different paragraphs. Is there some character or command that represents a hard return?

Here is the code I am using, how would I make the body of the email show "hello" and "next" on different lines in the email?

DoCmd.SendObject acSendNoObject, , , , , , "test", "Hello Next",0

I would want it to show up in the body of the email as follows:



Your help is greatly appreciated.

SendObject To RTF???
Does anyone know how to "send" an image to an RTF document?
When I use the SendObject command, it only sends the output of the Database report i.e. The field values. There are graphics that need to accompany it.


Need Help With Sendobject
I am developing an extenal sales software that will synchronize with the inhouse software. This software will go to our travelling salespeople, who will complete the order, and then email the necessary details to my company. There are a total of 5 tailored/trimmed table that I need to send, and here is where I run into trouble.

1) I do not know the correct syntax to put all 5 tables in the same email
    I have tried the SendObject command, and while it is not really reliable with Access 2000, it is clunky. I can get all five files to go out in 5 different emails by converting to Excel format, but is there a way to put all 5 in the same email?

2) I have also thought of outputting all 5 files using the append/update query to an external database, and then emailing that database. I do not know how to put in the relative shortcut location in with the database's location, and then emailing it.

Any ideas?

Thanks in advance!


Help Using SendObject Action
I have created a macro in Access 2000 that uses the SendObject Function to e-mail a particular query (saved as an excel spreadsheet). I need to send two queries because there are too many columns to fit the entire data I need in one query. Is there a way to attach more than one query to be sent in the same e-mail?

Any ideas/help would be much appreciated.

SendObject Report
Hi all,

I would like to have an additional attachment added automatically to mail message generated by the SendObject-SendTo command. One of the parameters is templateFile:

expression.SendObject(ObjectType, ObjectName, OutputFormat, To, Cc, Bcc, Subject, MessageText, EditMessage, TemplateFile)

I can't seem to figure out what exactly the TemplateFile parameter is used for?

The best solution possible for me would be to have an outlook template (.oft) open as my message. Any solution would be helpful.


SendObject Question
I have a form that has a button connected to a macro. The macro has
only one item :sendObject.

When I open the database and press the button, everything works fine.
Then...if I want to press the button again...nothing happens!

I have to close the database and reopen it for the button to work.

What command can I use to refresh the button, I have tried to use
refresh form..but it does not work.



SendObject AcSendTable
We have converted our ACCESS programs from 97 to 2000.

In one of them we use this command :

DoCmd.SendObject acSendTable, "mismatchpbu", acFormatXLS, _
alladresse, "", , _
"Mismatch DC and MPP for Supplier : " + supplier + " Pbg : " + pbgseek + " Pbu : " + pbuseek + " Vendor : " + VEND, messagetext + messagetext1, False

We send a table named "mismatchpbu" produce in the module using Outlook (we have to send several tables)

Just after the conversion we have some troubleshootings , some time only the first table is sent, some other times it's a limited number of tables......
However I have checked that the command SendObject run for all the tables to send.

If anybidy have an idea ????


SendObject Method
I have a SendObject Method which sends e-mail to a recipient. This process works fine in Access 97 but after converting the database to Access 2002(XP) there is a problem. Nothing displays in the "To" or "MessageText" of the e-mail client. The e-mail client is "GroupWise 5.5". Any assistance would be appreciated.

Converted ACCESS 2002 Code:
DoCmd.SendObject acSendReport, "rpt Specific Supervisor Assignments", acFormatRTF, Email_Address, , , "Audit Assignments", Supervisor_Name & " the latest Case Audit Assignments are now available.", 0

Supervisor_Name and Email_Address are variables being passed.


Colours In A Mail Using Sendobject
Hi folks,

I am sending an email using docmd.sendobject in Access 97. I build up my message from a recordset and then make this my message body. I do not actually send an object with the mail.

docmd.SendObject acSendNoObject, , acFormatTXT, strMailTo, , , strTitle, strMessage, False

This is all fine. What I want to find out is, is there any way I can add colours to the message? For instance, if one of the fields in my recordset goes above a certain tolerance, I would like to change that particular number to red.

Cheers in advance

Sendobject Action Was Cancelled
I am using the simple Report Operations to email a report that is based on a parameter query. When I hit the button, it asks for Vendor Number (which it should since it is a parameter query) and then I get the

The SendObject action was cancelled....


Private Sub Command14_Click()
On Error GoTo Err_Command14_Click

Dim stDocName As String

stDocName = "RptEmail"
DoCmd.SendObject acSendReport, stDocName

Exit Sub

MsgBox Err.Description
Resume Exit_Command14_Click

End Sub

Attaching More Than One Object Using The Sendobject Command.
I was wondering whether anyone could help, I want to attach more than one report in an email which will be sent when a button is pressed on a Microsoft Access Form, I can get one report attached using the following code:

Private Sub SendEmail_Click()
    Dim MessText
    Dim EmailAttachment As String
    EmailAttachment = "rptaddress"

    MessText = "Hello please find the information in the  attached file"
          DoCmd.SendObject acReport, EmailAttachment, _
              To:=Me.EmailAddress, _
              Subject:="Test Message", _
              MessageText:=MessText, _
End Sub

Unfortunatley this only attaches one report, does anyone know how to write the code so that more than one report can be attached.



Renaming Of Output File In SendObject
I am running DAO method in Office 2K environment.

Currently, I am working on a export/email function that I would like to enhance a little. The steps involved would be as follow:
    1) Openquery to create table ExportInfo.
    2) Use SendObject method to allow the users to transmit that table through emails via XLS format.

The XLS attached to the email is always named "ExportInfo.XLS", and I wonder if there is a way to rename that file to something else in the email, like forexample, instead of ExportInfo.Xls, it would be renamed to "Info022304.XLS"

(i.e. Info + Date())

Any idea?

What Is The Send Command In Word Like The Sendobject In Access
I am trying to code an word document to have a button to click and send a document. In access it it is sendobject....... and excell it it activeworkbook.sendemail Do you know what it is for a word document

DoCmd And Do Until
I would like to create a clear button that clears 4 check boxes (in Access.) Originally this wasn't a problem a table was used and I had the code:


Do Until Me.Recordset.EOF

But now, instead of a table, the customer would like to use a query. I'm sure this is just as simple, but I can't figure out how the code would work. I have never used queries before and looking at it, it looks like DoCmd is used, but I'm not sure how you could loop with the DoCmd.

Any help would be appreciated.



i am moving an application from Access to VB6 and SQL server. I have the following line of code and was wondering if there is an easy way to convert it to be able to work with the new system

DoCmd.TransferText acExportDelim, "DailyDDCollection", "tblDailyDDCollection", strFileToSaveAs

I am using ADO 2.7 by the way


Hi All,

Can anyone tell me what does this DoCMD Mean? Where do I use it exactly and when?



Docmd In Vb
Hi all,
I am using the followinf code for import dbf files to mdb in one shot, but i am not able to inderstand ths 'docmd' object can any one please help me in this.

John Philip
Dim con As ADODB.Connection
    Dim rst As ADODB.Recordset

    Set con = New ADODB.Connection
    Set rst = New ADODB.Recordset
    con.Open "accounts", , strDatapwd
    rst.Open "tblBatchImport", con, adOpenForwardOnly, adLockOptimistic
    Set doCmd = CreateObject("access.doCmd")
    Me.MousePointer = 11


    Do Until rst.EOF
        doCmd.TransferDatabase acImport, rst("TableType"), _
              rst("SourceDirectory"), acTable, rst("SourceDatabase"), _
              rst("ImportName"), False


***  Even the Best, did the Bad and Made the Best ***

John Philip

Need Help Using DoCmd In VB
I am trying to use the DoCmd object in VB to open a form and to run a macro in Microsoft access, but I keep getting
undefined variable when I code as follows:
DoCmd.RunMacro "mymacro"
DoCmd.openform "myform"

It is like visual basic does not recognize the docmd object

DoCmd.ApplyFilter In VBA
I´m trying to apply this filter to run a query based on two combo boxes:

DoCmd.ApplyFilter , ("strCountry= ' " & cboCountry & " ' ") And ("strStudy= ' " & cboStudy & " ' ") -----the quotes are separated for readability------

When i run each filter separately it works like a champ but when I put them together it doesn´t work...

What am I missing, does anybody knows?


Using DoCmd.FindRecord
Using Access 2000

I have an app that tracks information across several years, broken into two categories -- current year and previous years.

If a user puts in a social security number and hits "Find", the program queries the Current tables first. I thought I could use

DoCmd.FindRecord strSoc, acAnywhere, False, acSearchAll, False, acAll

where strSoc is my search string.

If the social sec. number isn't found in the current data, I manually build an ADODB recordset with the criteria as the source, and move the data into the current tables (by inserting new records), then, I use

DoCmd.GoToRecord , , acLast

to go to the newly inserted record, and it displays perfectly.

My problem is with data that already exists in the current tables...the find function is not working properly, and I get a "runtime error 2162: A macro set to one of the current field's properties failed because of an error in a FindRecord action agrument"

Any suggestions?

I am doing a project for college and want to make a form close after a button click opens a different form. So basically, i want the form to close after a new one is opened.

I have come across the command line "DoCmd.Close()", however, I don't understand the parameter's that you must use with it.

Can anybody help me with this problem?
Thank you.

I use DoCmd.TransferDatabase like this to export some tables to another database:

DoCmd.TransferDatabase acExport, "Microsoft Access", sDBFile, acTable, t, t
The problem is that I have sorted some fields in the source database,
and the sort doesen't follow? Why?

hi all,

its just me again some i have a question i don't know where to place it is either VBA or database ( i think). ok here we go

stDocName = "select cust"
DoCmd.OpenQuery stDocName, acNormal, acEdit
this 'select cust' is a sql query in access. can i pass a search string with this call and if not who would i do so.


DoCmd Problem
I need to be able to display/report and print data stored in an Access database. I had thought this would be relatively simple, and had tried using Crystal Reports but could not manipulate the data properly. (Please see my previous thread “Crystal Reports HELP!!” on 02-04-2002 in Visual Basic Help section if you have any suggestions, as I got no replies!)
I have now decided to try and use the methods of the DoCmd object to run Access actions from VB using DAO. This should hopefully allow me to open forms and use SQL to manipulate the data etc. and also print it out. But when I use “DoCmd.OpenForm...” I get:
Run-time error ‘438’
Object doesn’t support this property or method
I’ve already got the VBA, runtime obj & proc., obj & proc. And DAO 3.51 object library referenced. Am I still missing a reference? Is there somewhere I can find out which libraries I need in cases like this?
Any help appreciated, as I seem to going round in circles now – and I thought I’d done all the hard work already – I just want to display and print my results.

DoCmd Problem
i'm using the DoCmd.RunSQL to run a query. I set up my query on lines 8-9. My problem is on line 11. When the DoCmd.RunSQL is executed I'm prompted to enter in a parameter. I have already given it a value with strPLNum(j). I have other queries similar to this one and I do not have that problem.

What am I doing wrong? Can anyone help me.



1 For i = 1 To (rst.RecordCount)
2 strNum = Trim(Str(i))
3 strNum = "[FIND NO] = '" & strNum & "'"
4 MsgBox strNum
5 With rst
6 .FindFirst strNum
7 If .NoMatch = False Then
8 strBuffer = "UPDATE [PL-03] SET [PL-03].[NHA] = " &
9 strPLNum(j) & " WHERE [FIND NO] = " + Str(i) + ";"
10 MsgBox strBuffer
11 DoCmd.RunSQL strBuffer
12 ElseIf .NoMatch = True Then
13 j = 1
14 End If
15 End With

Is This Possible {DoCmd.OpenQuery}
.DoCmd.OpenQuery " SELECT " & TxtManual.Text & " FROM Time ", acViewNormal

I have this line of code saying object required as an error.

What i want to have happen is that when i open a query called time i only want the time and date entered in the text box to appear is this possible

Need VB Reference For DoCmd
I am new to VB. Is there a website or something that give reference code for docmd (an access code)

Shell? DoCmd?
I am currently calling a batchfile to use the print procedure:
print %1
call from in VB:
Shell print.bat file.txt

I've been trying to call the print procedure from within VB, but always get errors.
Can someone help me out here?

What Is The Refernce For DoCmd?
What reference do I need to add to my project so I can use the CoCmd object

Vba DoCmd.openReport Help
hi there,
i have a form, there are 4 combo boxes on the form each one dealing with a different field. i want the user to select a field from one or more of these combo boxes and use their selection to generate a report.

heres my code for the generate button to create the report:

Private Sub cmdGenerate_Click()
Dim AdvisorStr As String
Dim TeamStr As String
Dim MonthStr As String
Dim SubjectStr As String
Dim stDocName As String

stDocName = "rptCustomFilter"

On Error GoTo Err_Click
'set each of the variable to wildcard if no data selected
If cboNameSelect.Text = "" Then
AdvisorStr = "*"
AdvisorStr = cboNameSelect.Text
End If
If cboTeamSelect.Text = "" Then
TeamStr = "*"
TeamStr = cboTeamSelect.Text
End If
If cboMOnthSelect.Text = "" Then
MonthStr = "*"
MonthStr = cboMOnthSelect.Text
End If
If cboSubjectSelect.Text = "" Then
SubjectStr = "*"
SubjectStr = cboSubjectSelect.Text
End If
'check a filter has been selected
If AdvisorStr = "*" And TeamStr = "*" And MonthStr = "*" And SubjectStr = "*" Then
MsgBox "You must select a filter to generate a report", vbCritical, "Select Filter!"
'open report with selected filters
DoCmd.OpenReport stDocName, acViewPreview, , "[Subject]" = SubjectStr And & _
"[Team]" = TeamStr And "[Advisor Name]" = AdvisorStr And "[Error Against Month]" = MonthStr
MsgBox "you have the following data " & TeamStr & MonthStr & SubjectStr & AdvisorStr, vbInformation, "Info"
End If

Exit Sub

MsgBox Err.Description
Resume Exit_Click

End Sub

i put a message box after the DoCmd to ensure the information was in the variables, which it is, but the report opens with no information on it, regardless of what field is chosen or not.

if i do this:

DoCmd.OpenReport "ReportName",AcViewPreview,,"[Subject]=Form!ErrorSelect!cboSubjectSelect.Text"

then it works fine, but if my variable is the same as the value in the combo box, why wont it use this?

any help would be very much appreciated, or if you can suggest an easier or better way to do what i am trying to do i would be greatfull.

Brian :P

Help With DoCmd.OpenReport
hello, i was wondering if anyone could help me with opening an access report to a specific record so that when i print the report, it only prints the report for that record and not all of the records. i have an access.application and i can open the report in print preview mode, but it is the where clause that i can not seem to figure out.

thanks for help in advance, PJ

DoCmd.RunSQL !!!!!!!!
Can someone please tell me why when I try to run this code:

<code>DoCmd.RunSQL "SELECT * FROM MyTable WHERE MyTable.Date BETWEEN '" & startDate & "' AND '" & endDate & "';"</code>

I get the error from MS Access - 'A RunSQL action requires an argument consisting of an SQL statement'

I've tried this a billion different ways, including assigning the string to a variable and referencing that, but it no work


Docmd.Outputto Help
I am trying to output the result of a query to an excel worksheet. But I
want only the filtered data to go to the sheet. Records are filtered based
on the user input on a form. The command I am giving is as follows:

DoCmd.OutputTo acQuery, "Get_country_Info", "MicrosoftExcel(*.xls)", "C:Documents and SettingssagarwalMy DocumentsDatabase est.xls", True, ""

where "Get_Country_Info" is a predefined query.
It gives me the details of all the countries but I only want the countries which the user selects from the list box in the form

Is there a way I can write the query itself in the OutputTo command? I tried to substitute the query itself instead of passing the query object as follows:

DoCmd.OutputTo acQuery, "select country_name from country where country_name in ( " & tempcountry ")", "MicrosoftExcel(*.xls)", "C:Documents and SettingssagarwalMy DocumentsDatabase est.xls", True, ""

where tempcountry is a list of selected countries by the user. But it gives me an error saying
"database engine could not recognize the oblect 'select country_name from country where country = 'USA'' "

Any ideas??? Thanks in advance.

DoCmd (1312)
I managed to show up the custom properies window of selected shape when I click on the drop down list item of combo box. But first I want to show up the properties of the shape that I indicate in the code (visShape) - not the selected shape from the Visio draw page. Then when I close the custom properties it gives me error - Run-time error '-20324669555(86db03f5). I don't know where I'm wrong. Please, give me some hints or tell me what I have to add or change in the code.
Here is my code:

Private Sub ComboBox1_Change()

Dim visShape As Visio.Shape
Set visShape = ActivePage.Shapes.Item(4)

Select Case ComboBox1
Case "hardware devices"
visShape.Application.DoCmd (1312)
Case ...
End Select

End Sub

DoCmd Function
Hi All,

I have the following code inside and access database,

DoCmd.OpenReport "DockAudit", acViewPreview

However when it opens, the report is blank, but If I close the page and manually open the report it is showing all the data.

Has anyone seen issues with this command before?



"Victory goes to the player who makes the next-to-last mistake."
- Chessmaster Savielly Grigorievitch Tartakower (1887-1956)

DoCmd And Return Value
I am trying to run an Access macro from vb using the DoCmd. This will be running as a scheduled task. I do not see that the DoCmd or the RunMacro method return a value to show that the process completed successfully. Is this true? Is there another method/object to use that does return a value?

I need to update a log file, but only if the process completed successfully.



Using DoCmd.GotoRecord ???
Hi Gurus

I have managed to validate for null values for mutliple records on a continous form, but i am still trying to put the focus into the
field without teh value

here is my code below, i am trying to use the gotorecord so that the focus is on the right rcord on the form and then
set focus to that field, but i cant get it to work..any ideas??????????

Dim anum As Integer
   anum = 1
    Dim validate As Boolean
    While Not Me.RecordsetClone.EOF

        If ((Me.RecordsetClone.selected) = True) Then
            validate = IIf((IsNull(Me.RecordsetClone.ownerid)), True, False)
            If (validate = True) Then
                 validatefields = False
                MsgBox ("You donot have a value for the record" + str(anum))
                DoCmd.GoToRecord acdatafrom, "tbltransit_request", acGoTo, anum
                Exit Function
            End If
        End If
         anum = anum + 1

Thanks for your time, much appreciated


DoCmd Doesn't Do

I am very new to VBA and I am trying to import a csv file into access using Vba

Code:Private Sub Import_Click()

DoCmd.TransferText acImportDelim, ConstructionEstimateTable, "C:ConstructionEstimatesConstruction Estimates Import.csv", False

End Sub

I am getting an Variable Not Defined Error message
What am I doing wrong?


I am trying to use a filter before my report displays: Here's some of my code:
msaccess.docmd.openreport "report1",acviewpreview
msaccess.docmd.applyfilter, "store= '1'"

I get an error message telling me that the "applyfilter action can be carried out only from an open macro or open event procedure"...

Does anyone see something wrong with this ?
thanks in advance.

I am sending an Access Report from my VB App. using the DoCmd object:

Set objAccess = New Access.Application

objAccess.OpenCurrentDatabase "\Ntserver_sqlAccessjsdata........mdb"
objAccess.DoCmd.SendObject acReport, sReport, "RichTextFormat(*.rtf)", sRecipient, "", "", "Test", "", False, ""
objAccess.Quit acQuitSaveNone

The code was working fine yesterday and this morning. It was doing what I needed it to do - email a Report (sReport) to the supplied email address (sRecipient).

Now when I run it I get an error:
Error Number: 2293
Error Description: Microsoft Access can't send this email object.

Does anyone know if there are other alternatives to my code above for sending email or does anybody know of a fix for this?

Thanks as always!

DoCmd.OutputTo Appending?
Hi All,

I would like to loop through a list which would output a report to a file for each iteration. How could I append the file instead of having it over written?

Public Sub OutputReport()

DoCmd.OutputTo acOutputReport, "Report1", acFormatRTF, "C: empMyDatabase.rtf"

End Sub


Copyright © 2005-08, All rights reserved