Pulling Value from table in Access(VBA)

E

eric1025

I am currently using Redemption to send email. The way it assigns
values is by using the = "whatever". I want to pull data from my
options table for some values.

For example, instead of .Subject = "access..." I want to use .Subject =
Options.Access1

My options table and Access1 field will have the value I want to use.

Below is an portion of the code as it is now:



Set myOlApp = CreateObject("Outlook.Application")
Set MyItem = myOlApp.CreateItem(0)
Set safemail = CreateObject("Redemption.SafeMailItem")
Set safemail.Item = MyItem
Set mynamespace = myOlApp.GetNamespace("MAPI")
'mynamespace.Logon "myProfile", "myPassword", True, True ' Choose a
Profile
Set myfolder = mynamespace.GetDefaultFolder(5)
With safemail
.Recipients.Add (strSendTo) ' Send To
.CC = strCC ' Carbon Copy
.Attachments.Add (strAttachPath) ' Attachment 1
'.Attachments.Add (strAttachPath2) ' Attachment 2
.Subject = "Access Form for user: " & ID2
 
R

Ron Hinds

I am currently using Redemption to send email. The way it assigns
values is by using the = "whatever". I want to pull data from my
options table for some values.

For example, instead of .Subject = "access..." I want to use .Subject =
Options.Access1

My options table and Access1 field will have the value I want to use.

Below is an portion of the code as it is now:



Set myOlApp = CreateObject("Outlook.Application")
Set MyItem = myOlApp.CreateItem(0)
Set safemail = CreateObject("Redemption.SafeMailItem")
Set safemail.Item = MyItem
Set mynamespace = myOlApp.GetNamespace("MAPI")
'mynamespace.Logon "myProfile", "myPassword", True, True ' Choose a
Profile
Set myfolder = mynamespace.GetDefaultFolder(5)
With safemail
.Recipients.Add (strSendTo) ' Send To
.CC = strCC ' Carbon Copy
.Attachments.Add (strAttachPath) ' Attachment 1
'.Attachments.Add (strAttachPath2) ' Attachment 2
.Subject = "Access Form for user: " & ID2

If it isn't a form bound to the table "Options" then use a Recordset:

Set rs = CurrentDb.OpenRecordset("SELECT Access1 FROM Options WHERE [enter
your crieteria here]")

If Not rs.EOF Then
strSubject = rs!Access1
End If

rs.Close

.... rest of your code ...

..Subject = strSubject

If it is a form bound to the table "Options" then it's even easier:

.... rest of your code ...

..Subject = [Access1]
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top