Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Reading first record instead of current record

Status
Not open for further replies.
Mar 10, 2004
53
US
I have a form with an email button that is supposed to open up an Outlook window. It does open the outlook window but it seems to be getting the email information from the first record and not the current record.

What am I missing here?

Thanks in advance.

---------------------------------------

Dim sBodyText As String
Dim sSubject As String
Dim sAddress As String
Dim dba As DAO.Database, rst As DAO.Recordset

Set dba = CurrentDb
Set rst = dba.OpenRecordset("contact directory")

sBodyText = "test"
sSubject = "your subject"

If Not IsNull(rst("e-mail")) Then
sAddress = rst("e-mail")
DoCmd.SendObject , , , sAddress, , , sSubject, sBodyText
End If
 
Since you've just opened the recordset, the first record IS the current record.

You probably need to do something like

rst.FindFirst "ContactName = '" & TheContact & "'"

to position yourself properly.
 
Actually, there's really no need for me to open a recordset. Happen to come across an example that did and used it. Just needed to change the assignment to:

Set rst = Me.recordset

...and that did the trick.

Thanks.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top