R
Raistlin
OK, firstly please forgive the crossposting (and feel free to remove it, I
wasn't sure where this belonged).
Secondly, down to the problem (which I'm hoping someone can help me sort
out).
I am using the SendObject method from with VBA as the on click action for a
button on a form.
The idea is that when you click on the button Access creates an email using
info from the form.
The "To:" field for the email is an address contained in a completely
separate table in the database. The table has only 2 fields and 1 record
and it's sole purpose is to provide this email address. The reason I have a
separate table is because I want to be able to edit this address as and when
required without having to edit the code each time.
What I have so far is:
Table:
Table Name: HelpDeskDetails
Table Fields: HelpDeskID (Primary key, the value of this field for the one
record in the table is 1)
HelpDeskEmail (The email address I need to find)
Now, I'm guessing that I need to store the email address in a variable as a
string and then use the name of that string as the reference in the "To:"
part of the SendObject method. So what I've tried to do is open a recordset
based on the current database and then use a SELECT query to find the email
address (I'm doing this code from memory as the database is at work so
please bare with me):
'Declare Variables
Dim StrEmail As String
Dim rst As Recordset
Dim dbs As Database
Dim StrSQL As String
'Set Values
Set dbs = CurrentDb
Set StrSQL As "SELECT [HelpDeskEmail] FROM HelpDeskDetails WHERE
[HelpDeskID] = 1"
Set rst As dbs.OpenRecordset(StrSQL)
As I say, I'm not sure that I've got the code here exactly as it appears in
my database (but hopefully you can see what I'm trying to achieve), what I
need to do (I think) is pass the result of the SELECT query (which should be
only one email address) to the variabl StrEmail and then insert it into the
"To:" parameter of the SendObject method.
Hopefully what I've put above should make some sense, if anyone needs any
more information to help me sort this mess out then please let me know.
Regards, and thanks.
Raist.
wasn't sure where this belonged).
Secondly, down to the problem (which I'm hoping someone can help me sort
out).
I am using the SendObject method from with VBA as the on click action for a
button on a form.
The idea is that when you click on the button Access creates an email using
info from the form.
The "To:" field for the email is an address contained in a completely
separate table in the database. The table has only 2 fields and 1 record
and it's sole purpose is to provide this email address. The reason I have a
separate table is because I want to be able to edit this address as and when
required without having to edit the code each time.
What I have so far is:
Table:
Table Name: HelpDeskDetails
Table Fields: HelpDeskID (Primary key, the value of this field for the one
record in the table is 1)
HelpDeskEmail (The email address I need to find)
Now, I'm guessing that I need to store the email address in a variable as a
string and then use the name of that string as the reference in the "To:"
part of the SendObject method. So what I've tried to do is open a recordset
based on the current database and then use a SELECT query to find the email
address (I'm doing this code from memory as the database is at work so
please bare with me):
'Declare Variables
Dim StrEmail As String
Dim rst As Recordset
Dim dbs As Database
Dim StrSQL As String
'Set Values
Set dbs = CurrentDb
Set StrSQL As "SELECT [HelpDeskEmail] FROM HelpDeskDetails WHERE
[HelpDeskID] = 1"
Set rst As dbs.OpenRecordset(StrSQL)
As I say, I'm not sure that I've got the code here exactly as it appears in
my database (but hopefully you can see what I'm trying to achieve), what I
need to do (I think) is pass the result of the SELECT query (which should be
only one email address) to the variabl StrEmail and then insert it into the
"To:" parameter of the SendObject method.
Hopefully what I've put above should make some sense, if anyone needs any
more information to help me sort this mess out then please let me know.
Regards, and thanks.
Raist.