Send mail based on a record

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

Does anyone know the syntax to call on a record (say Autonumber 1,2,3...)
then return the record in a linked table of email addresses?

Thank you for any help on this.

A.
 
If you have a reference to DAO then this code should get you what you want,
when you pass it the desired record number (say Autonumber 1,2,3...) to get
the email address from. You will also need to specify the correct Table, and
Field Names for "MyLinkedTable" and "FieldNameContainingEmailAddress" ...
Hope this helps...

Private Sub GetEmailAddress(TheNumberOfTheDesiredRecord As Integer)

Dim daoDbs as DAO.Database
Dim daoRec as DAO.Recordset
Dim strSqlSelect as String
Dim strEmailAddress as String
Dim intMyDesiredRecordNumber as Integer

Set daoDbs = CodeDb

intMyDesiredRecordNumber = TheNumberOfTheDesiredRecord

strSqlSelect = _
"Select MyLinkedTable.* " & _
"From MyLinkedTable " & _
"Where MyLinkedTableIDRecordNumber = ' & intMyDesiredRecordNumber & " ;"

Set daoRec = daoDbs.OpenRecordset(strSqlSelect)

If Not (daoRec.BOF AND daoRec.EOF) Then

strEmailAddress = daoRec("FieldNameContainingEmailAddress").Value

Else

MsgBox "No Record Available.",vbInformation,"No Record Available:"

End If

Exit Sub

End Sub
 
Just in case you are not sure about the DAO Reference here is something
posted by
Ken Snell whom is an <MS ACCESS MVP>

You just need to set a reference to the DAO library (it's not set by default
in ACCESS 2000 and 2002). Open Visual Basic Editor, click Tools |
References, and select the Data Access Object library (3.6).

Note that DAO and ADO have some objects with the same names (e.g.,
Recordset), so disambiguate any DAO objects using DAO. in the declaration.
 
THANK YOU. This should work fine.

sparker said:
Just in case you are not sure about the DAO Reference here is something
posted by
Ken Snell whom is an <MS ACCESS MVP>

You just need to set a reference to the DAO library (it's not set by default
in ACCESS 2000 and 2002). Open Visual Basic Editor, click Tools |
References, and select the Data Access Object library (3.6).

Note that DAO and ADO have some objects with the same names (e.g.,
Recordset), so disambiguate any DAO objects using DAO. in the declaration.
 
Back
Top