473,396 Members | 2,002 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,396 software developers and data experts.

(rs.BOF and rs.EOF = true) but Record Count = 1

I've got a problem I have't run up against before. I generally test
for an empty recordset using BOF and EOF. Today, for the first time I
ran into a problem where my recordset shows BOF and EOF = true despite
the fact that there is has an actual record (record count = 1). The
count is correct, there should be one record (it shows on the form),
but it is not accessible in the recordset. Does anyone know why this
might be? The code is as follows:

txtSearch is a text box...the code snippet below runs when the user
hits FIND. The forms recordsource uses the search box as part of its
criteria (basically, find records where ID is like txtSearch:

dim RS as recordset

If IsNull(txtSearch) Then
msgbox ("Please enter a search criterium.")
txtSearch.Setfocus
Else
Me.Requery
txtSearch = Null
Set RS = Me.RecordsetClone
msgbox ("RecordSet: " & (RS.BOF And RS.EOF))
msgbox (RS.recordCount)
End If

RESULTS: msgbox1) RecordSet: TRUE
msgbox2) 1

The record will display on the form, but trying to do msgbox(RS(0))
will give an error. What is going on. The table it is searching is a
linked table to a SQL backend, but I don't think this should make a
difference since it is linked.

Thanks,
Ryan
Nov 13 '05 #1
1 10559
Hopefully you will get replies from people who use SQL Server more than I.

I've never seen this in Access/JET.
Try being explicit about the type of Recordset you are declaring, e.g.:
Dim RS As ADO.Recordset
or whichever is appropriate. With ADO recordsets, you can get a RecordCount
of -1 for undetermined.

Presumably txtSearch is unbound. It is not clear how the query is filtering:
perhaps you refer to Forms!Form1!txtSearch in the criteria of your query.

Is there a possible timing issue, where no records are loaded yet when the
1st MsgBox runs, but the record is loaded after its delay? To test that
idea, combine the 2 into one MsgBox:
strMsg = "BOF: " & RS.BOF & ". EOF: " & RS.EOF & _
". RecordCount: " & RS.RecordCount
MsgBox strMsg

--
Allen Browne - Microsoft MVP. Perth, Western Australia.
Tips for Access users - http://allenbrowne.com/tips.html
Reply to group, rather than allenbrowne at mvps dot org.

"Ryan" <ry************@kp.org> wrote in message
news:b5**************************@posting.google.c om...
I've got a problem I have't run up against before. I generally test
for an empty recordset using BOF and EOF. Today, for the first time I
ran into a problem where my recordset shows BOF and EOF = true despite
the fact that there is has an actual record (record count = 1). The
count is correct, there should be one record (it shows on the form),
but it is not accessible in the recordset. Does anyone know why this
might be? The code is as follows:

txtSearch is a text box...the code snippet below runs when the user
hits FIND. The forms recordsource uses the search box as part of its
criteria (basically, find records where ID is like txtSearch:

dim RS as recordset

If IsNull(txtSearch) Then
msgbox ("Please enter a search criterium.")
txtSearch.Setfocus
Else
Me.Requery
txtSearch = Null
Set RS = Me.RecordsetClone
msgbox ("RecordSet: " & (RS.BOF And RS.EOF))
msgbox (RS.recordCount)
End If

RESULTS: msgbox1) RecordSet: TRUE
msgbox2) 1

The record will display on the form, but trying to do msgbox(RS(0))
will give an error. What is going on. The table it is searching is a
linked table to a SQL backend, but I don't think this should make a
difference since it is linked.

Thanks,
Ryan

Nov 13 '05 #2

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

6
by: Hari Om | last post by:
Here are the details of my error log files: I execute the command and get following message at console: ---------------------------------------------------------------------- ../sqlldr...
3
by: thomasp | last post by:
I am trying to get a record count of a PHP query on a MS Acess database using ODBC with a DSN for MS ACCESS connection. I got this code from the PHP manual user notes. It seems to return the...
2
by: DC Gringo | last post by:
I have a datagrid control that has paging set up and working. What I would like is a total record count (not just per page) in the header or near the header of the datagrid. Here's my code: ...
1
by: darrel | last post by:
I'm trying to whip up a fancy repeater control that will put records into a two-column table for me. This is how I envision it working: itemtemplate if record count = odd then write out the...
7
by: Mike | last post by:
I have a form where I have turned off the default navigation buttons. I then created my own. This works fine. The only questions that I have is on the default navigation buttons it shows total...
4
by: Peter W Johnson | last post by:
Hi guys, I have a problem with a datagrid record count. Here is the code:- <snip> Public Class frmMerchantDeposit Inherits System.Windows.Forms.Form Dim myconnection As New...
7
by: hjohnson | last post by:
Within the access environment, I have a table that I'd like to -add a column -place the record number of each record into that column The autonumber is not working for me because I am...
7
by: CampbellJD1 | last post by:
I am using Access 2003 Professional. I have been working with Access for some time and I have created an MDB with a Linked Table and the Data there is temporarily transferred to other Table for...
2
by: John | last post by:
Hi I am using the below statement; Me.MyTableAdapter.Fill(Me.MyDataSet.tblMyTable) How can I now check the record count of the data table and specifically if the record count returned by...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.