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 Westi on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

How do you reference the current record in a Form?

Status
Not open for further replies.

rccline

Technical User
Jun 13, 2002
341
US
reference: Basic VBA question
thread705-352369


I've got a similar problem...to that posed in Thread 705-352369. Being a novice at this, I am asking some very basic questions here.


Am basing my record-set on a Query. This isn't working out because the query doesn't know which email I am on. I am creating the email on a form.

So my Subject, and the body should not be rst!Subject, or rst!Body, rst!EmailID, but some reference to the current record in the form I am using.
The clickevent on the form will send the email to all those in the query, but with only the current record showing subject and body.

How do I refence that?

Many thanks!

Robert



Code:
Dim rst As DAO.Recordset
Dim dbs As DAO.Database

Set dbs = CurrentDb
Set rst = dbs.OpenRecordset("QrySendEmail")

If (Not rst.EOF) And (Not rst.BOF) Then
rst.MoveFirst
While Not rst.EOF

  strSubject = rst!Subject
  strMsg = "Dear " & rst!FIRSTNAME & " " & rst!LASTNAME & ":" & vbCrLf & vbCrLf
  strMsg = strMsg & rst!Body & " " & rst!Note & vbCrLf & vbCrLf
  strMsg = strMsg & "Regards, Robert" & vbCrLf & vbCrLf & "Email ID: 00" & rst!EmailID
 
Hi Robert

Make the record source of the form where you input the EMAil Message you query (qrySendMail).

Put the EMail adderss etc on the form as bound fields, (hide them if you wish by setting visible property to false)

Make a means to navigate to the record you want, depending on how many records you have this could be a combobox to allow you to choose a person by name or simple navigation buttuns to allow you to move through the record set record by record

Have a button to send the email, pick up the EMail address etc, from the Email Adderss control on the form, ie you get an email to the 'current' person only.

Regards
Ken Reay
Freelance Solutions Developer
Boldon Information Systems Ltd
UK
kenneth.reay@talk21.com
 
Thank you Kenneth for taking the time to answer my question.

Robert
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top