I'm currently creating a database for my work that consists of basic information on the company car fleet. I've created the database and front sheet which consists of variables such as car,c ar color, MOT Date, Tax Date, etc.
I need to somehow have Access detect when a company car's MOT date is due and email someone to notify them that the date is upcoming by comparing today's date with the date entered into the MOT date field.
Something like, if today's date is a week prior to the MOT date, send an email to whoever to notify them that this is due.
I need this to happen automatically, I plan to open and refresh the sheet daily so it doesn't need to be particularly fancy and do it without Access being open, I just need it to perform this task without trawling through pages and pages of data.
You can do this on launch. Just write a query that picks the records you want. Then loop through the query and fire off an email to each person, then make sure you have a field called "EmailSent" that you'll update to True so you don't send them an email the following day (assuming you just want to email them once).
You'll probably just want some VBA along these lines:
Dim db as Database
Dim rec as Recordset
Set db = CurrentDB
Set rec = db.OpenRecordset("SELECT * FROM MyQueryName")
Do while rec.EOF = False
'Loop through each record, send them an email
'Add code to send email here
rec.MoveNext
'Now update the table so these guys don't get emailed again
dim MySQL as String
MySQL = "UPDATE MyQueryName SET EmailSent = 'True'"
DoCmd.RunSQL MySQL
The above is all "aircode" and is untested, but should set you in the right direction.
Just make sure EmailSent = False is a condition in your query.
Related
There are some tutorials that explain how to email someone on their birthday. What I am looking for is to send a single email with the list of all the people who celebrate their birthday that day.
I would like to know how I can send in the body of the email the name of the people who celebrate their birthday on that day.
I have been working on a flow with each of the following steps:
Recurrence:
With this step I send my daily mail every certain hour.
Get items:
I created a sharepoint list where I have the name of the birthday boy, date of birthday (DOB), gender and department.
Initialize variable:
Apply to each
Append to string variable
I add to the Birthdays variable the value that would be the name of the employee whose birthday is that day that is in the sharepoint list
Send an email
In the step of sending an email, I add the previously initialized variable "Birthdays" to the body of the email, which should contain the list of employees whose birthday is that day
I have supported myself with this question made in the Microsoft Power Automate forum but it does not work as it should since I am new to power automate
Error:
At the moment of executing my manual flow I get in the condition as a result false in addition to two errors when I add the variable and send the mail
Can someone give me an orientation in knowing what I am doing wrong in the flow since my mail does not arrive either.
UPDATE:
The value of the Birthdays variable at runtime is as follows:
UPDATE 2:
I have added in Filter Query the following expression formatDateTime(utcNow(),'dd-MM-yyyy') eq 'listColumn' but when executing the manual flow I get that The expression "28-01-2022 eq 'listColumn'" does not It is valid.
Annex error that shows me in the execution of the manual test
UPDATE 3:
The column in the sharepoint list where I am storing the birthday date is called DOB:
Get Items action you should use Filter Query row to search something like: formatDateTime(utcNow(),'dd-MM-yyyy') eq 'listColumn'.(You should have a column in sharepoint containing all user birthdays).
[1]: https://i.stack.imgur.com/Y3s4S.png
Append to String all the emails that you get from GetItems: Email;
Try this one; it should work:
Birthdays eq '#{formatDateTime(utcNow(), 'yyyy-MM-dd')}'
I'm have trouble coming up with a solution to a staff availability form, for a live event facility.
The goal is to have someone in the office select start and end dates, which generates a list of upcoming events. This list will be seen by employees on WebDirect, and they will be able to mark whether they are available or not via checkbox. The people in the office will then be able to see who is available for the all upcoming events while scheduling.
The idea behind choosing the start and end date is so the office can selectively "publish" which dates the employees see, as well as having a log of all responses tied to that form.
I also want to limit the employee to only be able to see their responses to the form.
So far I have tables as follows:
Employee Event Availability Form Response
-------- ----- ------------ ---- --------
ID ID ID ID ID
Name Date StartDate fk_AvailabilityID fk_EmployeeID
Title EndDate fk_ResponseID Checkbox
All of the relationships are primary key = foreign key except Event Date has a relationship to Availability:
Date ≥ StartDate AND
Date ≤ EndDate
Not really sure where to go past this or if this even is correct to begin with. I've experimented with a FormResponse table but not really sure what connections to make.
I'm fairly new to FileMaker and Databases in general, so laymens terms would be appreciated.
For starters, instead of convoluted relationships, you could use a field in the event table as a publish flag and then perform a search for that in web direct upon login.
When the staff sets a start/end date, they run a script that sets the publish flag for these records only.
To match the logged in user to an employee, you would need to store the account name in the employee table and match these upon login. Then set the privileges such that records can only be viewed when there is a match.
Hope this helps.
I want to know if there is a plugin or somehow to notify via email to moodle users if they have not connected since xxxx date to complete a course.
Is there a way to make this automatically via cron or so?
Thanks.
You're question is a 2 in 1. You're asking how to identify users who haven't signed on in a while, and how to email them. I'm going to answer in parts accordingly. All of this can be accomplished via cron, but I don't use Moodle so I don't know what plugins are available to you.
He's an example of a query that would identify users who haven't logged on in 180 days (but it will ignore those who have never logged in).
SELECT * FROM mdl_user
WHERE lastlogin < UNIX_TIMESTAMP(DATE_SUB(NOW(), INTERVAL 180 DAY))
AND lastlogin != 0
AND lastaccess < UNIX_TIMESTAMP(DATE_SUB(NOW(), INTERVAL 180 DAY))
AND deleted = 0
Now for the email bit. Per Google, Moodle uses the PHPMailer for it's email_to_user() function. An example of using this in PHP:
email_to_user($toUser, $fromUser, $subject, $messageText, $messageHtml, '', '', true);
$toUser and $fromUser should be Moodle user objects, not email addresses. Traversing your query results to build these objects would be all that's left to do.
Last tip: To get a user object based on each result of your query, you can use the get_record function like so:
$userObj = get_record("user", "id", $userID);
Big question: How can I make Access automatically fill in a cell in a form based on previously entered data?
I need to enter leave details for members of staff. I tend to enter these by date, and in one to two week chunks. Is there a way to have the next new record automatically fill in the date part of the record with the previously entered one?
Table structure
Staff: StaffID, Name
Absences: ID, StaffID, Dateaway, OtherDetails
I want it to automatically fill in DateAway with the entry of the row above it, or the previously entered row, as I will enter say 10 dates in a fortnight, but 50 entries over those dates. I enter them chronologically, and after the fact (So just defaulting to TODAY() won't work).
There's a shortcut Ctrl+' that does pretty much what I need, wondering if there's a way to do that with the generation of a new record.
You have to be careful with this. If your form is bound to a table/query, you're going to insert a junk record every time you're done with the form. However, if it's unbound you can do this using DMAX, in the After Insert event of the form.
Private Sub Form_AfterInsert()
txtDateaway.Text = DMax("Dateaway", "Absences", "StaffID = " & Me.txtStaffID)
End Sub
This is, of course, assuming your Dateaway field on your form is called txtDateaway and your StaffID field is called txtStaffID.
Is it possible to have a macro that changes the order of the cells within an excel doc, and then immediately changes them back?
In Column C I have a list of dates. I would ideally like to have the macro order all of the rows by date, send the email I need in this order, and then have it go back to the (more or less) random order it is in now.
Is that possible?
If you were wondering this is how you sort the dates
Sub SortByDate()
Dim rSortRange As Range
Dim ws As Worksheet
Set ws = Sheets("Sheet1")
Set rSortRange = ws.Range("N11", "N111")
rSortRange.Sort Key1:=ws.Range("N11"), Order1:=xlAscending
End Sub
And you can run this code to send a email if you are using outlook
Application.Dialogs(xlDialogSendEmail).Show