Link to home
Start Free TrialLog in
Avatar of Sandra Smith
Sandra SmithFlag for United States of America

asked on

Set a variable to the one field in a recordset object

This is the start of a complicated email, but I am taking it in steps.  I have begun with the outer most loop in that I need to get all the TaskID's from a query, but how to I assign each TaskID to the variable for the loop?  that is, each time through the outside loop, I want to use the TaskID and then move to the next TaskID and use that for the next loop.  
Private Sub cmdGenerate_Click()
'Generate final email to manager
Dim strUpdateHistory As String
Dim strUpdateCurrent As String
Dim strUpdateTitle   As String
Dim qdfUpdateHistory As QueryDef
Dim qdfUpdateCurrent As QueryDef
Dim qdfUpdateTitle   As QueryDef
Dim strTaskID       As String


Set rst = CurrentDb.OpenRecordset("Select TaskID from qryTasks_UpdatesEmail")
'HOW TO SET THE VARIABLE TO THE TASKID FROM THIS SELECT QUERY
With rst
  Do While Not .EOF
  
Set qdfUpdateTitle = CurrentDb.CreateQueryDef("qryUpdateTitle", strUpdateTitle)
DoCmd.OpenQuery "qryUpdateTitle"
DoCmd.Close acQuery, "qryUpdateTitle"

Open in new window

ASKER CERTIFIED SOLUTION
Avatar of Rey Obrero (Capricorn1)
Rey Obrero (Capricorn1)
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of Sandra Smith

ASKER

Capricorn1, thanks.  I had the strTaskID in the wrong place.  As stated, this is teh start of a long and complicated email, so there will more questions soon.