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!

How to run SQL in an MS Access module 1

Status
Not open for further replies.

ftpdoo

Programmer
Aug 9, 2001
202
GB
Dim tbl As TableDef
Dim db As Database
Dim rs As Recordset


Set db = CurrentDb
Set rs = db.OpenRecordset("SELECT * FROM Electricity")


I've written the code above.. How do I view the contents of this SQL? ie rs.item(1) to view the first item etc?

Have I even got this setup right? Its not bring back any results.

Thanks
ted
 
You have to move to the first record, and then to each record in turn

if not (rs.eof and rs.bof) then
rs.movefirst
do until rs.eof
debug.print rs(1)
rs.movenext
Loop
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top