pulling SQL records

  • Thread starter Thread starter Joel Allen
  • Start date Start date
J

Joel Allen

Outlook 2003 SP3

Hello,

I run select queries from within my code to populate certain fields from a
SQL database. I need to run a "For each" command and am not having luck.

This is what I have so far. For each record it finds, I want it to do
something. Am I going about this wrong?

Set EachRecord = Nothing
Set EachRecord = rst.Open "Select * FROM tblCO WHERE JobNumber = '" &
Item.UserProperties("JobNumber") & "'", _
oADOConn, adOpenKeyset, adCmdTable

For EachRecord
msgbox"hi"
Next


Thanks Joel
 
You might loop through an ADO recordset like this:

rst.movefirst
while not rst.eof
debug.print rst.fields("abc").value
rst.movenext
wend

See the ADO help file for details. This has nothign to do with Outlook.

--
Best regards
Michael Bauer - MVP Outlook

: Outlook Categories? Category Manager Is Your Tool
: VBOffice Reporter for Data Analysis & Reporting
: <http://www.vboffice.net/product.html?pub=6&lang=en>


Am Fri, 28 Aug 2009 16:17:44 -0700 schrieb Joel Allen:
 
Back
Top