Modules & VBA :: Send Task To Recipient Using Late Binding
Oct 2, 2013
I am trying to send tasks to other people using access vba. I had used before in my database but was using early binding and now through version issues of office I am trying to recreate the code using late binding, however I am getting various problems with certain lines of code.
Primarily .datedue line I am getting run time error 438 object does not support
Below is my code:
Public Sub ASB5PostponedTask()
Dim olApp As Object
Dim olTask As Object
Dim olDateEnd As Date
Dim ToContact As Object
Dim olTaskOwner As String
olTaskOwner = "e.grainger"
I am trying to send an MS Access 'report' as an attachment to a mail recipient in rtf format without success. Everything seems to work fine except the 'send' button. Click away and nothing happens.... no error messages, no nothing. Any suggestions or tips on how to make this work?
I have a query that may have 6 - 7 different records for example each record contains a different email address, i need to get the first email then send and email to that address then go to the next record get that email address send an email to that email address until its gone through all the records...
I use this code to send an email, dont know how to loop through records and get the email...
Code: Dim appOutLook As Outlook.Application Dim MailOutLook As Outlook.MailItem Dim strPath As String Dim strFileName As String Set appOutLook = CreateObject("Outlook.Application")
I have created a database that auto emails and works well, my problem now is that though there are multiple emails to send to it is only sending to the first one. The way I have set this up is I have created a qry to combine all emails using Allen Brownes concatrelated in below
Code: SELECT DISTINCT Left([Copy Of tbl_Depot]![Depot],3) AS Port, ConcatRelated("[Copy Of tbl_Depot]![ContactEmail]","[Copy Of tbl_Depot]","[Copy Of tbl_Depot]![Port]=""" & Left([Copy Of tbl_Depot]![Depot],3) & """") AS Email FROM [Copy Of tbl_Depot];
I then link this to an append qry which becomes my data source
Code: INSERT INTO tbl_dptem ( [Empty Return Location], [Container], ContactEmail, DepotEmSent ) SELECT qry_emdepot1.[Empty Return Location], ConcatRelated("[qry_emdepot1]![Container No]+chr(13)+chr(10)","qry_emdepot1","[qry_emdepot1]![Empty Return Location]= """ & [qry_emdepot1]![Empty Return Location] & """") AS [Container], qry_Portem.Email, qry_emdepot1.DepotEmSent FROM qry_Portem RIGHT JOIN qry_emdepot1 ON qry_Portem.Port = qry_emdepot1.[Empty Return Location] GROUP BY qry_emdepot1.[Empty Return Location], qry_Portem.Email, qry_emdepot1.DepotEmSent;
Below is the code I use to auto send emails and when I check it shows all email addresses in sent email but it is only going to the first recipient.. not sure what I need to do so all of them get it.
Code: Sub EmDepot() Dim Notes As Object Dim Maildb As Object Dim MailDoc As Object Dim objNotesDocument As Object Dim objNotesField As Object
I have been able to create code to send email for my ticket system but now have a need to add an additional recipient. I would prefer this recipient to be add in the CC field. This email address will come from its own table. I have tried to figure this out myself but I can't get anything to work for me . I am fairly new to VBA and all of my experience is just through trial and error (mostly error). I have attached my original code below ....
Private Sub cmdMailTicket_Click() On Error GoTo Err_cmdMailTicket_Click Dim stWhere As String '-- Criteria for DLookup Dim varTo As Variant '-- Address for SendObject Dim stText As String '-- E-mail text
I have the following code (which everyone uses) but I have a challenge.
I ONLY want to use two (maybe three) fields from the database! (Subject & Body... with the POTENTIAL of an attached document.
I want to fill in the "to" section AFTER the email is open. This will allow me to make changes if I need to before it is sent.
Here is the code I am trying to work with. (It should look familiar) but I can't get it to keep outlook open!
Code: Private Sub SecondEmail_Click() 'open Outlook, attach zip folder or file, send e-mail Dim appOutLook As Outlook.Application Dim MailOutLook As Outlook.MailItem
I write Access 2010 apps in VBA that require no knowledge of Microsoft Access on the part of the user. My forms contain all the necessary controls to use the program without relying on any of the Microsoft Access toolbars. I call this "de-Microsofting" the app. When I prepare the .accdb program to create a .accde app, I uncheck every checkbox (Options/Current Database) except "Compact on Close". This works well, but it also hides the Windows taskbar at the bottom of the screen. Some of my users need to be able to jump from my app to others (e.g., Excel) and back without having to exit my app. How can I force the Windows taxkbar to always be on top using VBA or, possibly, some setting?
I have a vbs-script that opens my access database db.mdb and runs the module "Export":
dim accessApp set accessApp = createObject("Access.Application") accessApp.OpenCurrentDataBase("D:Datadb.mdb") accessApp.Run "Export"
accessApp.Quit set accessApp = nothing
This works fine as a scheduled task on a Windows 7 computer.
Is there a way to make this work on a Windows Server 2008 R2 ? When I double click the vbs-file, the file opens instead of runs. And when I create a scheduled task, nothings happens.
I have a query that formats data into a list of personnel who are coming due for refresher training. The query is formatted to provide me all the details that I need to create an outlook task, and assign it to the person. I tried creating a button on my form to create a record set of that query, and then create / assign a task to each person based on the values from the recordset.
Code: Private Sub SendTasks_Button_Click() 'Create the recordset and set it to the appropriate query Dim rst As DAO.Database Dim rstData As DAO.Recordset Set rst = CurrentDb Set rstData = rst.OpenRecordset("SendTasks_qry")
[Code] .....
Basically, the compiler stops at "Dim myOlApp As New Outlook.Application" with the error: "Compile error: User-defined type not defined"
Thanks again for the help I've received here. Sorry if I appear a bit clueless at times; I'm a medical student, not a programmer :)
Let's say I have one table for a variety of disease: primary key field would be the disease; other fields would include fields for various symptoms, fields for various etiologies (causes), and a field for the drug of choice to treat it. Now, let's say I wanted to link this table to another table, one which records all the drugs used (the drug name field being the primary key), their mechanisms of actions, their uses, their side effects, their contraindications, etc... Now, maybe I'm misunderstanding the normalization rules, but wouldn't including the name of the drug used to treat the disease in the first table while simultaneously having a second table listing all drugs violate normalization rules? If not, is the task of relating the table as simple a matter as defining the drug name field of the disease list table as the foreign key in a relationship to the drug name field (the primary key) of the drug list table? Or is there a much simpler way to do this?
Well, as part of my new job I get to revise a current database for a client and I am hitting a brick wall in my mind at the moment and could use some ideas thrown my way on how to deal with it.
First of all I have two tables -
Table AR_Due AR_Due_ID - Autonumber (PK) Entity_ID - Long Integer (FK) AR_Due_Amt - Currency AR_Due_Date - Date/Time AR_Due_Waive (boolean and if checked the amt due is forgiven and not due)
Now, I have to pull all AR_Due where the payments are late (past the AR_Due_Date) and have no in the Waive column and, if partial payments were made those payments can't be past the due date or else they need to be included as late (that's my main issue - trying to figure out the logic on that one).
So, any ideas on how that might be best accomplished? I need a report that shows all late payments (not counting lates more than two years ago) including any where there were partial payments made but the total partial payments were not made before the due date.
I'll take any ideas, although I might not be able to use some of them due to having to follow certain standards here (don't know all of them yet but I've kind of figured a few out based on the existing db). And, I didn't put this all together so there are some things I can't change (at least at this point), but I'm happy to get any ideas that might spark the "aha" moment :).
I have 4 revised ship date columns, an est ship date, and an actual ship date. I have a column summing days late for est ship date and one summing revised days late. The expression I am having problems with is to calculate the total days late for the revised. I want it to check the 4th revised and if it has a date calculate from that date. If not I want it to go to the 3rd and calculate from that, and so on. I have pasted the code I was trying to use. It just goes all the way to the bottom of the code and calulates from the 1st revised ship date. I have also attached a jpg of the layout of the columns. I also want to do this in the query using expression builder.
I ran into this error message with the SendObject method. I'm getting the email address from the "username" environment variable. Our company generally uses the logon ID as the first part of everyone's email address, but there are some users that get this error: "Unknown message recipient; the message was not sent" Not only that, if two sendobjects are used one after the other, sometimes it sends to the first person and then the second one is set up to send a copy back to the sending user, it doesn't recognize the recipient that's logged on and is actually trying to send the email. That's the one that comes from the environment variable. But I've tried hard-coding the recipient and bypassing the variable altogether and it still generates the same error.
I have a query in Access and a word document that opens up the query. Currently the query contains every record in the database. If I alter the query in Access to select a certain set of records (based on dates) when Word opens the recipient list is empty. Checking for errors it says there were no records or no data records matched query options.
How can I get Word to open and use the modified query?
I am trying to create a textbox control that uses an expression. I then want this expression to be stored in a field in a table I have created. Can someone help me with this please?
I have a form. The form is bound to an underlying query which is a left join between two tables. (SELECT ... T1 LEFT JOIN T2 ON T1.RID = T2.RID ....)
Now, what I want to happen is the value in T1.RID does have a match in T2, then I want a sequence of text controls to be bound to fields from T2, otherwise I want them to be bound to fields in T1.
I almost have it working. I have Form_Current() and T1_RID_Change() both calling a routine
sub BindControls() if isnull(T2_RID.value) then txtField1.Controlsource = "T1.Field1" txtField2.Controlsource = "T1.Field2" ' etc for each field else txtField1.ControlSource = "T2.Field1" txtField2.ControlSource = "T2.Field2" ' etc for each field end if end sub
The problem is that when I change the value in T1.RID, most of the times it does change the controlsource appropriately. But other times it lags. It keeps the wrong controlsource until I try changin RID again, and sometimes the text boxes are just blank, so I am not sure what is going.
Am I ultimately going to be able to make this scenario work?
I wonder if it's possible to bind one form to more than one table without using 'sub-form'? I basically have one text box that I want to bind to a different table than the one the form is linked to and I don't know if I should use a subform.
Hello Everyone, I am stuck in a problem for many days now. In the form, on which I am working, there are 2 dropdown lists (combo box). The data in the first combo is coming from a list and in the second combo, I am running a query, and depending upon the selection in the first combo, the data in the second combo may come from one of many tables in the database. What I want is to have control over the data, before it is being displayed in the second combo, as the data in have many null and 'same name' entries. But what I don't want is to change the original data in the tables.
Till now, I have been trying to make use of persistant recordset, that is, by storing the recordset in an external table, changing its data and binding it to the second combo. But I am unable to bind the data.
What in your opinion, is the best approach to accomplish this. A snippet will be of great help as I am not a experienced programmer.
Hy,i have some ADO recordset and i want to bind it to blank report that I made in reports.How to do this. If i create report in reports section and after that i want to see it in my code as that same object and set his record or data source property how to do this?? I know that you can set the recordsource property directly in report but it includes some values from textbox in my form that doesn't show corectly(it's an array of numbers,and i don't know why it doesn't accept it). Thanks
I have the code for sending an email but I only want to send a single email when there are records in a query and only when the database is first opened.
I hadn't considered this in my design so what structural requirements would it require if any?
I currently have a code set up which sends an attachment from a drive on my computer to all the email addresses in a certain query. I would like to change the code so that I can add a button that will allow me to send an email with a specific attachment depending on their individual code in a table, e.g each person will receive a specific attachment. At the moment, the attachments are saved with the same file name as the person's specific code.The code I am currently using is:
Private Sub Command9_Click() Dim MyDb As DAO.Database Dim rsEmail As DAO.Recordset Dim qdf As DAO.QueryDef Dim prm As DAO.Parameter Dim strEmail As String Dim strMsg As String Dim oLook As Object
Since my old DB had hyperlink (web pages) either starting with http:// or not, and the users were complaining that they couldn't easily edit the field, I converted all the fields to text. Then I tried the following code on doubleclick:
Dim WebLink As String If Me.WebPage2 <> "http//" & "*" Then WebLink = "Http://" & Me.WebPage2 Else WebLink = Me.WebPage2 End If Debug.Print WebLink Application.FollowHyperlink WebLink, , True
The above works fine if there is no http:// but if there is one already in the text, then I get run time error 5 that it cannot locate the page. On checking what is happening, the code is adding http:// again even if it already there.
I use this to send email msgs through gmail, found it on the net somewhere, adapted a bit and it works.
Code: Private Function fSendGmail() As Boolean 'Returns True if No Errors are Generated On Error GoTo Err_ErrorHandler fSendGmail = True Const conStrPrefix As String = "http://schemas.microsoft.com/cdo/configuration/" Const conCdoSendUsingPort As Integer = 2
[Code] ....
Err_ErrorHandler: If Err.Number <> 0 Then fSendGmail = False etc, etc End Function 'fSendGmail
I'd like to send report attached to this as pdf or rtf. How should I go about it. I know how to create pdf and save it.(DoCmd.OutputTo acOutputReport, "My Report", acFormatPDF, strPath, True) But where do I attach that here? Is it necessary to save the file first?
I use a macro that attaches a document automatically to an e-mail address ready to send this report is governed by a query of which the criteria is " loss order number " this is in a pdf format of which I need if possible
The problem I have is the same pdf file keeps attaching itself to the e-mail no matter which loss order number I select. The reason I think is because the report is called NCR so it is not changing from the previous one. What I think can solve it but not sure and don't know how to do is get the " loss order number " within the report name.
If I just send the report to a file direct it does work as I am prompted for a file name
Can the loss order number get into the file name within a macro/vba