RecordCount Problems With ADODB 2.6

Feb 28, 2005

The company I work for remains on the 2.6 version of the various MDAC components. Unfortunately, upgrading is not an option that I can control. So....

When I open a recordset which DOES contain records, I often return a RecordCount of -1. EOF is false, so that is working, and I am able to use that to get around part of my problem. Where I need the count after iterating through the recordset, I am able to use an iCounter variable to get that. I have tried using MoveLast, MoveFirst, etc. before calling for RecordCount, but that does not help.

In many instances having the count BEFORE going through the recordset would be very helpful. Has anyone else ever encountered this problem? Anyone devise a workaround?

Thanks in advance for any help!

John

View Replies


ADVERTISEMENT

Help With Recordcount Command

Jul 14, 2006

I am trying to count how many records has a table with a special value (SolicitaçãoID.Text) but I keep getting error:
Compile Erro:
User-Defined not defined

And it goes to this line: Dim db As DAO.Database

This is the command:

Private Sub CmdAmostra_Click()
Dim db As DAO.Database
Dim rs As DAO.Recordset
Dim intResult As Integer
Dim strSQL As String

Set db = CurrentDb
SolicitaçãoID.SetFocus
strSQL = "SELECT COUNT (*) As RecordCount FROM Protocolo_O where SolicitaçãoID=" & SolicitaçãoID.Text
Set rs = db.OpenRecordset(strSQL, dbOpenSnapshot)

intResult = rs("RecordCount")

MsgBox intResult

Amostras.SetFocus
Amostras.Text = intResult

rs.Close
db.Close

End Sub

Well i have no clue what that error means and why.
Thanks for the Help
Art

View 9 Replies View Related

RecordCount Please Help! Im Stuck

Oct 6, 2006

Thanks for looking at my post. What I have done is this, i have built a custom search form for my access database. What i need is a textbox that shows how many records will show up if the user clicks generate form.. I want this textbox to update every time the person changes his search criteria. For example

the person wants to search by address, by typing in

Gold into the address textbox the recordcount textbox would show the user if he were to press generate form he would get

1200 records

now if he changes the address to
GoldStone -- the recordcount textbox would then update to show only

14 records would be shown if he/she generated the form...
Here is my current code

***********
Set db = CurrentDb
Set qdf = db.QueryDefs("MainDB_Search")

For Each prm In qdf.Parameters
prm.Value = Eval(prm.Name)
Next prm

Set rs = qdf.OpenRecordset(dbOpenDynaset)
rsCount = rs.RecordCount

MsgBox (rsCount)
txtGenerateReport.Value = rsCount

************
Now the problem with this code is that it works the first time the user types in search criteria, however when he/she tries to change it from Gold to Goldstone -- nothing happens, it runs the code above and returns 1200 records instead of the correct 14...

Please help :)

Thanks

Jason

View 4 Replies View Related

Subform Recordcount Problem

Aug 25, 2006

I have several bound subforms whose recordsources are based on querydefs...

I use the following code in the OnCurrent event of the main form to count the number of records on a subform,

Me.mysubformname.Form.RecordsetClone.RecordCount

but for some reason, one particular subform won't give me the correct count... the only difference I can see between the problem subform and the others is that it is populated by a union query... any reason why that would be causing the problem? Any other thoughts?

Thanks in advance,
Scott

View 3 Replies View Related

Curious On Rich's Recordcount Advise

Nov 4, 2005

Rich helped Latex88 a little further down and the advise given was:

"=Count(*) in the control source of a textbox in the subform footer will do it, no vba is needed"

I tried this out out on a few of my subforms and it worked on all but one. The recordsource of the one that it does not work on is based on a query. When I changed the recordsource to a table then the recordcount works.

Curious as to why and is there a work around?

Thanks a head of time,
Shane

View 9 Replies View Related

Queries :: DAO RecordCount Versus Count Query

May 21, 2013

For small tables (<10,000 rows), which technique is faster, more efficient ?

View 11 Replies View Related

Remote Access Through ADODB

Nov 8, 2005

Hi everyone, I'm just a newbie in DB programming and I'm having a trouble:

I have a database located in my IIS server: "c:inetpubwwwrootwebapplication1dbs1.mdb".

I'm also developing a VB6 app in another computer which will access to my IIS server to get data in my database. I'm using ADODB, but I don't know how to establish the connection as well as to get the data from the server (remote machine).

Can anyone in here help me by showing an example in VB6 code?
Thank you very much, any sugestion is welcome
Reply With Quote

View 3 Replies View Related

Setting ADODB.Connection

Aug 14, 2006

I am trying to set up an unbound form inn access 2003 to link to a PostgreSQL database. Being a newbie to this sort of stuff, I am having a few problems. Using Access 2003 VBA Programmers Guide, I have found some code to help in what I am trying to do but I cannot get my head around the connection settings.

The code under the form General Declarations is:
Code:Dim rsTest As ADODB.RecordsetDim cnTest As ADODB.ConnectionDim boolAddNewMode As BooleanPrivate Sub pPopulateFields()' Check to be sure the recordset is not in a BOF or EOF state.' If it is then do nothingIf Not rsTest.BOF And Not rsTest.EOF Then' rsTest.Resync adAffectCurrentMe.job_number = rsTest.Fields("job_number")Me.customer_ref = rsTest.Fields("customer_ref")Me.pen_contract = rsTest.Fields("pen_contract")End If' Set focus to the Exit controlMe.cmdExit.SetFocus' Reset the text boxes and save/cancel buttons to a' locked or disabled state.Me.job_number.Locked = TrueMe.customer_ref.Locked = TrueMe.pen_contract.Locked = TrueMe.cmdCancel.Enabled = FalseMe.cmdSave.Enabled = False' Reset the boolAddNewMode flagboolAddNewMode = FalseEnd SubCode under on Open event of form:Private Sub Form_Open(Cancel As Integer)' For simplicity, we will use the built-in connection of the ADP.' If we were creating an MDB or connecting to a different SQL Server,' then the full connection string would need to be suppliedSet cnTest = Server.CreateObject("ADODB.Connection")cnTest.Open "FILEDSN=PostgreSQL"' Create the recordset and move to the first recordSet rsTest = New ADODB.RecordsetrsTest.Open "Digi Ticket", cnTest, adOpenDynamic, adLockOptimisticrsTest.MoveFirst' Populate the text boxes on the form with datapPopulateFieldsEnd Sub
I want to the form to pickup data using a filedsn called PostgreSQL from a table called 'public_digipen_tickets' and populate a form called Digi Ticket.

Can anyone offer any assistance.

thanks in advance.

View 4 Replies View Related

ADODB.Recordset Error '800a0bb9'

Oct 25, 2004

Hello,

I am new to asp so if anyone would be kind enough to help me i would appreciate it.
I am using macromedia dreamweaver to connect to an access database

This is the error i am getting

ADODB.Recordset error '800a0bb9'


Arguments are of the wrong type, are out of acceptable range, or are in conflict with one another. /results.asp, line 47

this is my code
Code: <<A href="mailto:%@LANGUAGE="JAVASCRIPT">%@LANGUAGE="JAVASCRIPT" CODEPAGE="1252"%><!--#include file="Connections/IDX.asp" --><%var MLSIDX__twn = "everett";if (String(Request('twn')) != "undefined" && String(Request('twn')) != "") { MLSIDX__twn = String(Request('twn'));}%><%var MLSIDX__type = "sf";if (String(Request('type')) != "undefined" && String(Request('type')) != "") { MLSIDX__type = String(Request('type'));}%><%var MLSIDX__beds = "1";if (String(Request('beds')) != "undefined" && String(Request('beds')) != "") { MLSIDX__beds = String(Request('beds'));}%><%var MLSIDX__baths = "1";if (String(Request('baths')) != "undefined" && String(Request('baths')) != "") { MLSIDX__baths = String(Request('baths'));}%><%var MLSIDX__min = "0";if (String(Request('min')) != "undefined" && String(Request('min')) != "") { MLSIDX__min = String(Request('min'));}%><%var MLSIDX__max = "999999999";if (String(Request('max')) != "undefined" && String(Request('max')) != "") { MLSIDX__max = String(Request('max'));}%><%var MLSIDX = Server.CreateObject("ADODB.Recordset");MLSIDX.ActiveConnection = MM_IDX_STRING;MLSIDX.Source = "SELECT * FROM mls WHERE LONG ='"+ MLSIDX__twn.replace(/'/g, "''") + "' AND PROP_TYPE ='"+ MLSIDX__type.replace(/'/g, "''") + "' AND NO_BEDROOMS >= '"+ MLSIDX__beds.replace(/'/g, "''") + "' AND NO_FULL_BATHS >= '"+ MLSIDX__baths.replace(/'/g, "''") + "' AND LIST_PRICE BETWEEN '"+ MLSIDX__min.replace(/'/g, "''") + "' AND '"+ MLSIDX__max.replace(/'/g, "''") + "' ORDER BY LIST_PRICE";MLSIDX.CursorType = 0;MLSIDX.CursorLocation = 2;MLSIDX.LockType = 1;MLSIDX.Open();var MLSIDX_numRows = 0;%><!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd"><html><head><meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1"><title>Untitled Document</title></head><body><%=(MLSIDX.Fields.Item("LIST_PRICE").Value)%><%=(MLSIDX.Fields.Item("LIST_PRICE").Value)%><%=(MLSIDX.Fields.Item("LAST_NAME").Value)%></body></html><%MLSIDX.Close();%>

any suggestions as to what i am doing wrong?

View 1 Replies View Related

Modules & VBA :: Stuck At ADODB Collections

Apr 29, 2015

I try to use collection of a ADODB.recordset eg rsTarget,Essentially I want to assign the fields (columns) in this rsTarget with respective data. I tried to use of

two sets. (fld as adodb.field)
Set fld = rsTarget.Fields.Item(count)
Set fld = rsTarget.Fields.Item(Column(count))

Then I try to use following to assign
RsTarget!fld.name = Data1

It failed stating that there is no fld.name. Using column set, it state that there is no column function. How to do it right?

View 2 Replies View Related

Modules & VBA :: Opening ADODB Recordset

Jul 2, 2013

I'm building a lab environment into one of my projects. I'm testing the distribution of values over a largish number of attempts to create a unique value.I have a table called LAB_UniqueIDTest, with two fields:

LAB_ID - the string value being tested, and
LAB_UsageCount - the number of times the value has been created.

I'm trying to open the table using the following code:

Code:

' Initialize access to the LAB_UniqueIDTest table
Set rs = New ADODB.Recordset
rs.Open "LAB_UniqueIDTest", _
CurrentProject.Connection, _
adOpenKeyset, adLockOptimistic

I have similar snippets of code all over the application - either with a literal (as here) or as a string parameter.I do not, ever, use the options parameter of rs.open.I get error message "Run time error -2147217900 (80040e14) Invalid SQL statement - expected DELETE, INSERT, PROCEDURE, SELECT or UPDATE

My guess is it's because somehow the Open procedure is trying to interpret the tablename as a SQL statement. But how come it isn't this obtuse at other times?

View 6 Replies View Related

SQL Statement For ADODB Recordset.filter Method

Feb 8, 2007

I want to use the NOT IN operator for the filter method of ADODB.recordset in VBA. Do anybody in the forum know the syntax.

View 3 Replies View Related

ADODB.Recordset (0x800A0BCD) Either BOF Or EOF Is True, Or The Current.....

Sep 2, 2005

ADODB.Recordset (0x800A0BCD)
Either BOF or EOF is True, or the current record has been deleted. Requested operation requires a current record.

Code:
<%
function combomaker(elSQL, elFieldNameID, elFieldName, elSelected, elConn)
' This function creates a generic combo box with values from a table
dim elRS
set elRS = server.CreateObject("ADODB.Recordset")
set elRS = elConn.Execute(elSQL)
elRS.MoveFirst

do while not elRS.eof
response.Write "<option value='" & elRS.fields(elFieldNameID) & "'"
if elSelected <> "" then
if cstr(elRS.Fields(elFieldNameID)) = elSelected then
response.Write " selected "
end if
else
if elRS.BOF then
response.Write " selected "
end if
end if
response.Write ">" & elRS.fields(elFieldName) & "</option>" & vbCrLf
elRS.MoveNext
loop
elRS.close
set elRS = nothing
end function
%>

View 1 Replies View Related

General :: ADODB Connection - Error In Loading DLL

Jan 16, 2013

I have windows 7 and office 2003 installed.

I have access application which was running fine recently but for some reason everytime I run it now it gives an error on the adodb connection string saying compile error.

Its doing this on every adodb connection I have in my database.

I have tried registering the dao an ado dlls but still the problem persists.

View 3 Replies View Related

2010 Runtime ADODB Connection Failure

Jul 3, 2011

I have a routine which connects to MySQL database with ADODB connection. This worked in 2003 and 2007 runtime but throws a 430 error on 2010 runtime. It works in full access 2010. Has there been a change of policy to restrict this type of connection in the 2010 runtime? If I use a linked ODBC table instead of ADODB the runtime fails with "Runtime Error". It still works in full access.

View 2 Replies View Related

Forms :: Filtering A Form Based On ADODB Recordset?

Oct 16, 2013

I have a form that shows records from ADODB recordset.When I try to apply filter to the underlying recordset it works all right but the form doesn't reflect the changes. It shows same rows as before filtering. In debug I can see that the recordset contains only filtered records. Me.Refresh (Recalc, Requery) doesn't work.

Code is as follows:

Dim rs As New ADODB.Recordset
rs.Open sql, conn, adOpenStatic, adLockOptimistic
Set Me.Recordset = rs

Sub combo_AfterUpdate()
Me.Recordset.Filter = "CompanyNo = 123"
End Sub

The form is in Continuous forms mode. I cant use DAO because the data comes from SQL server user-defined function.

View 5 Replies View Related

General :: ADODB - Unrecognized Database Format Error

Jun 9, 2014

I am getting the error " Unrecognized Database Format Error.

Sub ShowUserConnected()
Dim cn As New ADODB.Connection
Dim cn2 As New ADODB.Connection
Dim rs As New ADODB.Recordset
Dim i, j As Long
cn.Provider = "Microsoft.Jet.OLEDB.4.0"

[Code] ....

View 5 Replies View Related

Modules & VBA :: Access 2010 And ADODB Recordset Count

Nov 24, 2013

I opened a 2007 Access db in Access 2010. This DB worked perfectly in Access 2007, but when I opened it in 2010 my recordset.recordcount no longer works.

This is what I have:

rsGetInst was previously defined
Dim intInstCount as integer
Dim rsGetInst As New ADODB.Recordset
rsGetInst.CursorLocation = adUseClient
rsGetInst.CursorType = adOpenDynamic
rsGetInst.LockType = adLockOptimistic

rsGetInst.open "Select * from tblInstruction where CustID = " & intCustomerID
intInstCount = rsGetInst.recordcount

At this point a get a "type Mismatch" error, and it is happening in all my recordsets recordcount.

Is there a command or reference that needs to be change when using Access 2010. When I compared the references the only difference is that in 2007 we reference Microsoft Access 12.0 Object Library and in 2010 is Microsoft Access 14.0 Object Library.

View 1 Replies View Related

Modules & VBA :: Form Bound To ADODB Recordset Is Read Only - Cannot Edit?

Sep 4, 2013

I can't make edits with ADODB recordset bound to my form.

Access 2010 linking to SQL Server 2008.

Simple form bound to a single table.

Connection string works fine.

Code is as below (cursor etc is set using enums btw).

Private Sub Form_Open(Cancel As Integer)
Dim rst As ADODB.Recordset
If g1OpenRecordset(rst, "tblName", rrOpenKeyset, rrLockOptimistic, False) = False Then
Cancel = True
Exit Sub

[Code] ...

View 3 Replies View Related

General :: ADODB Connection - User Defined Type Not Defined

Feb 10, 2014

I have a line of code in an old program:

Dim CN as ADODB Connection

This is giving me the error 'User defined type not defined'. I know I have to set something in a list somewhere but have forgotten how to do that. Where to go, and what to set?

View 1 Replies View Related







Copyrights 2005-15 www.BigResource.com, All rights reserved