在Access 2003/2007中打开记录集 [英] Open recordset in Access 2003/2007
问题描述
距离我使用Access代码已经有好几年了,这无疑使我发疯.
It's been years since I've worked in Access code and it is making me certifiably insane.
我只是什么都不记得了,我所要做的就是用代码打开一个记录集,而我在网上找不到任何东西,或者我尝试过的任何代码排列都可以正常工作.
I just don't remember anything and all I want to do is open a recordset in code and nothing I've found online or any permutation of code I've tried works.
它的简称:
Dim rsSystem As Recordset
Dim sSQL As String
sSQL = "SELECT * FROM Table"
Set rsSystem = CurrentDB.OpenRecordset(sSQL)
我在圣地狱中想念什么?
What in the holy hell am I missing?
谢谢.
推荐答案
此处的示例针对打开"Recordset"的所有排列: http://www.vbexplorer.com/VBExplorer/vb_feature/june2000/Database_Beginner_ADO_DAO.asp
Examples here, for all permutations of opening a "Recordset": http://www.vbexplorer.com/VBExplorer/vb_feature/june2000/Database_Beginner_ADO_DAO.asp
最简单的方法是在当前数据库上使用DAO.我的VBA有点生锈,但是...
The easiest way is to use DAO on the current database. My VBA is a little rusty, but...
Dim db as DAO.Database
Dim rs as DAO.Recordset
Set db = CurrentDB
Set rs = DB.OpenRecordset("table or query name")
对于ADO:
Dim rs As New ADODB.Recordset
rs.Open "tblPeople", CurrentProject.Connection, adOpenDynamic
这篇关于在Access 2003/2007中打开记录集的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!