如何在Access中‧使用VBA執行SQL SELECT命令
操作方法
- 01
早兩天,有朋友問到在Access中‧用VBA執行SQL SELECT找尋,本來Access一早已經有SQL來過濾數據庫內資料,也不明白為甚麼要這樣做,反正有要求,也找一下資料。 Option Compare DatabasePublic Sub filter1() Dim db As DAO.Database, rec As DAO.RecordsetDim list(500) As String Dim i As IntegerSet db = CurrentDbSet rec = db.OpenRecordset("SELECT * FROM Jobs WHERE JobCat='ENGINEERING'") i = 0 While Not rec.EOFlist(i) = rec![JobCode] i = i + 1 rec.MoveNext Wend For j = 0 To i - 1 MsgBox (list(j)) Next j rec.Close db.Close End Sub
赞 (0)