Specific Record in Recordset (1 Viewer)

KeithIT

Registered User.
Local time
Today, 08:56
Joined
Dec 20, 2004
Messages
133
I am sending out personalized emails based on a response to a meeting invitation. What I would like to do is open a new recordset and pull information from a specific record within that set. I have code written to perform this task automatically for each reply. Replies are entered in groups so I am trying to avoid having to requery the recordset for each reply (although if I have to...). Is there a way to use .move or another command with an adodb recordset to move to a specific record and then perform the operations on that record?

Thanks in advance.
Keith
 

modest

Registered User.
Local time
Today, 08:56
Joined
Jan 4, 2005
Messages
1,220
When you pull data from a recordset, it automatically looks at one record at a time... all you have to do is point to the record.

You can do this with the

.Move command if you know it's place in the recordset, but generally people don't know what row it is. If you have data to look up use the .Find method.

Code:
Dim rst As ADODB.Recordset

rst.Find "[Field Name]='" & strValue & "'"

'then you want to make sure the record exists

Select Case rst![Field Name]
    Case strValue
        'it found the record -- perform operations
    Case Else
        'it couldn't find the record
End Select

You could also check using an if statment. Or you might want to filter the recordset instead... and then loop through it for each record that matched your search. There are many ways of coming to a solution.
 

KeithIT

Registered User.
Local time
Today, 08:56
Joined
Dec 20, 2004
Messages
133
Thanks so much! I looked through the list of commands that show up when you type "rst." but looked right past .find, figures. I assume, from a performance standpoint, that in a large recordset .find would be faster as it would stop once it finds the record that matches the parameters rather than scrolling through each record as .filter would do? That seems to make sense from a logic standpoint, but you never know... :rolleyes:

Thanks again for the help. :)
 

Users who are viewing this thread

Top Bottom