|
-
May 2nd, 2013, 05:39 PM
#1
Thread Starter
Frenzied Member
Trouble opening a recordset in Access 2007 form code
I'm using some very basic code copied from a project I did a couple of years ago.
In a Sub in the code page for a form in Access 2007, I'm using this code
Dim RS as Recordset
Set RS = CurrentDB.OpenRecordset("Select * from Table1")
It doesn't matter what I query, I get RS.Recordcount = 1, which I assume means it isn't getting the actual results
As I mentioned, I used this same code in another db before with no problem.
Also, in this same project, I've had no trouble using queries to populate objects.
It's the code above, just returning a recordset, that's causing the problem. And it isn't giving me any kind of error back. That's making it impossible for me to solve.
Any help would be appreciated.
Thanks.
Wen Gang, Programmer
VB6, QB, HTML, ASP, VBScript, Visual C++, Java
-
May 3rd, 2013, 01:12 AM
#2
Re: Trouble opening a recordset in Access 2007 form code
You have to MoveLast before reading the Recordcount so it will return the true number.
-
May 4th, 2013, 04:31 AM
#3
Re: Trouble opening a recordset in Access 2007 form code
do not rely on the recordcount property in ADO as it depends on cursortype and whether the recordset is dynamic, static or forward only
probably used to work ok in DAO
i do my best to test code works before i post it, but sometimes am unable to do so for some reason, and usually say so if this is the case.
Note code snippets posted are just that and do not include error handling that is required in real world applications, but avoid On Error Resume Next
dim all variables as required as often i have done so elsewhere in my code but only posted the relevant part
come back and mark your original post as resolved if your problem is fixed
pete
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|