I have a custom function in Access2007 that hinges on grabbing data out of a specific query. It opens Outlook, creates a new email and populates the fields with specific addresses and data taken from the query ("DecisionEmail")
.
Now I want to make a different query ("RequestEmail")
and have it populate the email with that data. So all I have to do is change this line:
Set MailList = db.OpenRecordset("DecisionEmail")
and that's where I get stumped.
This is my desired result:
If the user is on Form_Decision
and clicks the button "Send email"
, "DecisionEmail"
will get plugged into the function and that data will appear in the email.
If the user on Form_SendRequest
and clicks the button "Send email"
, "RequestEmail"
will instead get plugged in.
The reason that these are different queries is because they contain very different information that is smudged about in different ways. However, since it's just one little thing that needs to change in the function code, I don't think a brand new function is a good idea.
My last resort would be to make a brand new function and use the Conditions field in the Macro interface to choose between them, but I have a feeling there's a more elegant solution possible.
I have a vague notion of setting the query names as variables and using an If statement but I just don't have the mental vocabulary for thinking through this.