I have a form with a subform on it. When the user enters information
into the form, I create a sql query in vba and use it to open a
recordset. Then I set the subform's recordset to it.
Using DAO, everything works fine. When I rewrite the code to use ADO,
I get no records in my recordset.
'the dao code (returns records):
Dim d_db as DAO.database
Dim d_rst as DAO.recordset
Set d_db = currentDb()
Dim strTest As String
strTest = "SELECT tblA.AddressesI D, tblA.Address1 " & _
"FROM tblA " & _
"INNER JOIN lkpStates ON tblA.StatesID = lkpStates.State sID "
& _
"WHERE address1 LIKE '*17*' " & _
"ORDER BY Address1"
Set d_rst = d_db.OpenRecord set(strTest)
Set Me.subfrmLookup Address.Form.Re cordset = d_rst
'the ado code (doesn't return records):
Dim a_rst as ADODB.Recordset
Dim a_cnn as ADODB.Connectio n
Set a_rst = New ADODB.Recordset
a_rst.Open strTest, cnn, adOpenKeyset, adLockOptimisti c, adCmdText
Set Me.subfrmLookup Address.Form.Re cordset = a_rst
Can anyone tell me what I'm doing wrong? (My code assigns the
subform's recordset to either the DAO or the ADO recordset, not both
as here.) Also, why can't I close my DAO/ADO recordset object as soon
as I assign the form's recordset property to it? I assumed my
variables and the form's recordset were all pointers, but I guess not.
Thanks,
Sharon 4 3733
When you use ADO, JET uses the ANSI behavior for Like, not the DAO behavior.
This means that the *s are no longer wildcards, an you need to use %s instead.
If you want consistent LIKE behavior with JET via both DAO and ADO, you can
use the ALike (ANSI Like) operator. This operator uses the ANSI wildcards
regardless (always % and _, not * and ?).
On 29 Dec 2003 12:40:06 -0800, sh*********@inc amail.com (Sharon Stern) wrote: I have a form with a subform on it. When the user enters information into the form, I create a sql query in vba and use it to open a recordset. Then I set the subform's recordset to it.
Using DAO, everything works fine. When I rewrite the code to use ADO, I get no records in my recordset.
'the dao code (returns records):
Dim d_db as DAO.database Dim d_rst as DAO.recordset Set d_db = currentDb()
Dim strTest As String strTest = "SELECT tblA.AddressesI D, tblA.Address1 " & _ "FROM tblA " & _ "INNER JOIN lkpStates ON tblA.StatesID = lkpStates.State sID " & _ "WHERE address1 LIKE '*17*' " & _ "ORDER BY Address1"
Set d_rst = d_db.OpenRecord set(strTest) Set Me.subfrmLookup Address.Form.Re cordset = d_rst
'the ado code (doesn't return records): Dim a_rst as ADODB.Recordset Dim a_cnn as ADODB.Connectio n
Set a_rst = New ADODB.Recordset a_rst.Open strTest, cnn, adOpenKeyset, adLockOptimisti c, adCmdText Set Me.subfrmLookup Address.Form.Re cordset = a_rst
Can anyone tell me what I'm doing wrong? (My code assigns the subform's recordset to either the DAO or the ADO recordset, not both as here.) Also, why can't I close my DAO/ADO recordset object as soon as I assign the form's recordset property to it? I assumed my variables and the form's recordset were all pointers, but I guess not.
Thanks, Sharon
I just thought to wonder - why are you opening a recordset, then setting the
form's Recordset property when it's simpler and less problematic to just set
the form's RecordSource to the SQL statement (which would automatically be DAO
in an MDB and use the DAO wildcards for LIKE). Also, it appears that you are
working in an MDB, so the use of ADO anywhere at all probably has more
downsides than benefits, regardless of what Microsoft suggests.
On 29 Dec 2003 12:40:06 -0800, sh*********@inc amail.com (Sharon Stern) wrote: I have a form with a subform on it. When the user enters information into the form, I create a sql query in vba and use it to open a recordset. Then I set the subform's recordset to it.
Using DAO, everything works fine. When I rewrite the code to use ADO, I get no records in my recordset.
'the dao code (returns records):
Dim d_db as DAO.database Dim d_rst as DAO.recordset Set d_db = currentDb()
Dim strTest As String strTest = "SELECT tblA.AddressesI D, tblA.Address1 " & _ "FROM tblA " & _ "INNER JOIN lkpStates ON tblA.StatesID = lkpStates.State sID " & _ "WHERE address1 LIKE '*17*' " & _ "ORDER BY Address1"
Set d_rst = d_db.OpenRecord set(strTest) Set Me.subfrmLookup Address.Form.Re cordset = d_rst
'the ado code (doesn't return records): Dim a_rst as ADODB.Recordset Dim a_cnn as ADODB.Connectio n
Set a_rst = New ADODB.Recordset a_rst.Open strTest, cnn, adOpenKeyset, adLockOptimisti c, adCmdText Set Me.subfrmLookup Address.Form.Re cordset = a_rst
Can anyone tell me what I'm doing wrong? (My code assigns the subform's recordset to either the DAO or the ADO recordset, not both as here.) Also, why can't I close my DAO/ADO recordset object as soon as I assign the form's recordset property to it? I assumed my variables and the form's recordset were all pointers, but I guess not.
Thanks, Sharon
Thanks for the answers Steve.
I don't know why I wasn't just setting the RecordSource -- it's much
simpler to do it that way. Also, it appears that you are working in an MDB, so the use of ADO anywhere at all probably has
moredownsides than benefits, regardless of what Microsoft suggests.
You're right, I'm working in an MDB. I'm using ADO where possible
because the original idea was that this project would be upsized to
SQL Server (though that's looking more and more unlikely). What are
the downsides of using ADO in an MDB, assuming it doesn't get upsized?
-- Sharon
Steve Jorgensen <no****@nospam. nospam> wrote in message news:<m0******* *************** **********@4ax. com>... I just thought to wonder - why are you opening a recordset, then setting the form's Recordset property when it's simpler and less problematic to just set the form's RecordSource to the SQL statement (which would automatically be DAO in an MDB and use the DAO wildcards for LIKE). Also, it appears that you are working in an MDB, so the use of ADO anywhere at all probably has more downsides than benefits, regardless of what Microsoft suggests.
On 29 Dec 2003 12:40:06 -0800, sh*********@inc amail.com (Sharon Stern) wrote:
I have a form with a subform on it. When the user enters information into the form, I create a sql query in vba and use it to open a recordset. Then I set the subform's recordset to it.
Using DAO, everything works fine. When I rewrite the code to use ADO, I get no records in my recordset.
'the dao code (returns records):
Dim d_db as DAO.database Dim d_rst as DAO.recordset Set d_db = currentDb()
Dim strTest As String strTest = "SELECT tblA.AddressesI D, tblA.Address1 " & _ "FROM tblA " & _ "INNER JOIN lkpStates ON tblA.StatesID = lkpStates.State sID " & _ "WHERE address1 LIKE '*17*' " & _ "ORDER BY Address1"
Set d_rst = d_db.OpenRecord set(strTest) Set Me.subfrmLookup Address.Form.Re cordset = d_rst
'the ado code (doesn't return records): Dim a_rst as ADODB.Recordset Dim a_cnn as ADODB.Connectio n
Set a_rst = New ADODB.Recordset a_rst.Open strTest, cnn, adOpenKeyset, adLockOptimisti c, adCmdText Set Me.subfrmLookup Address.Form.Re cordset = a_rst
Can anyone tell me what I'm doing wrong? (My code assigns the subform's recordset to either the DAO or the ADO recordset, not both as here.) Also, why can't I close my DAO/ADO recordset object as soon as I assign the form's recordset property to it? I assumed my variables and the form's recordset were all pointers, but I guess not.
Thanks, Sharon
In my experience, it's actually better to keep using DAO with Access as a
front-end to SQL Server. ADO makes more sense in a VB project or VBA project
that is not in Access. I'll have time to post a longer reply later.
On 30 Dec 2003 13:12:41 -0800, sh*********@inc amail.com (Sharon Stern) wrote: Thanks for the answers Steve.
I don't know why I wasn't just setting the RecordSource -- it's much simpler to do it that way.
Also, it appears that you are working in an MDB, so the use of ADO anywhere at all probably has moredownsides than benefits, regardless of what Microsoft suggests.
You're right, I'm working in an MDB. I'm using ADO where possible because the original idea was that this project would be upsized to SQL Server (though that's looking more and more unlikely). What are the downsides of using ADO in an MDB, assuming it doesn't get upsized?
-- Sharon
Steve Jorgensen <no****@nospam. nospam> wrote in message news:<m0******* *************** **********@4ax. com>... I just thought to wonder - why are you opening a recordset, then setting the form's Recordset property when it's simpler and less problematic to just set the form's RecordSource to the SQL statement (which would automatically be DAO in an MDB and use the DAO wildcards for LIKE). Also, it appears that you are working in an MDB, so the use of ADO anywhere at all probably has more downsides than benefits, regardless of what Microsoft suggests.
On 29 Dec 2003 12:40:06 -0800, sh*********@inc amail.com (Sharon Stern) wrote:
>I have a form with a subform on it. When the user enters information >into the form, I create a sql query in vba and use it to open a >recordset. Then I set the subform's recordset to it. > >Using DAO, everything works fine. When I rewrite the code to use ADO, >I get no records in my recordset. > >'the dao code (returns records): > >Dim d_db as DAO.database >Dim d_rst as DAO.recordset >Set d_db = currentDb() > >Dim strTest As String >strTest = "SELECT tblA.AddressesI D, tblA.Address1 " & _ > "FROM tblA " & _ > "INNER JOIN lkpStates ON tblA.StatesID = lkpStates.State sID " >& _ > "WHERE address1 LIKE '*17*' " & _ > "ORDER BY Address1" > >Set d_rst = d_db.OpenRecord set(strTest) >Set Me.subfrmLookup Address.Form.Re cordset = d_rst > >'the ado code (doesn't return records): >Dim a_rst as ADODB.Recordset >Dim a_cnn as ADODB.Connectio n > >Set a_rst = New ADODB.Recordset >a_rst.Open strTest, cnn, adOpenKeyset, adLockOptimisti c, adCmdText >Set Me.subfrmLookup Address.Form.Re cordset = a_rst > >Can anyone tell me what I'm doing wrong? (My code assigns the >subform's recordset to either the DAO or the ADO recordset, not both >as here.) Also, why can't I close my DAO/ADO recordset object as soon >as I assign the form's recordset property to it? I assumed my >variables and the form's recordset were all pointers, but I guess not. > >Thanks, >Sharon This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics |
by: Marco Alting |
last post by:
Is it possible to INNER JOIN two recordsets in ASP? I don't mean the normal
JOIN you would use with two tables, but actually join the recordsets in ASP?
|
by: Steve Marciniak |
last post by:
I'm trying to display different recordsets (which are 1 field each) as
columns right next to one another. For example, Recordset1 is
displayed on the left hand side of the screen. Recordset2 is displayed
immediately to the right of then first recordset with the first rows
or each at the same level. Recordset3 is displayed to the right of
Recordset2 and so on. There is no set limit to the number of possible
recordsets (or columns to...
|
by: Steve Jorgensen |
last post by:
I keep having problems in which ADO disconnected recordset work under some
circumstances, but lose all their data at other times, having no rows or
fields, though the recordset object still exists.
One case where this happened to me today was in trying to store disconnected
recordsets in a cache collection in case they are needed again later in the
same session. When I retrieve the recordset from the collection, it's empty.
On the other...
|
by: Pieter Linden |
last post by:
The answer to this one is probably "test it yourself and find out!",
but I'll ask anyway. Pursuant to my previous question - sending
separate recordsets to Word using the CreateTableFromRecordset code
from ADH2000...
I will be opening like 8 recordsets {one for each building, and there
are 8). Would I be better off or is there anything to be gained by
opening one recordset of the query with _all_ the records in it,
filtering that, and...
|
by: lakshmi |
last post by:
Hi all,
I recently rewrote a data intensive C++ program in C#.
The C++ program was traversing 3 recordsets that were all
open at the same time. I replaced those 3 recordsets with
3 .NET data readers and found that my C# code takes only
about 35% of the time that the old C++ program took to
execute. I'm amazed at this performance improvement, but
finding it hard to believe. I'm supposed to make a
recommendation based on my test results.
| |
by: Randy Harris |
last post by:
I was inspired by the recent discussion of returning multiple recordsets to
ADO from a stored procedure. (Amazed is probably more accurate). I asked
about how to accomplish same with Oracle and got a nudge in the right
direction from Mr. Kreft. I promised to provide details once working, so
here it is.
The code is shown below. My next step is to build this technique into my
application. I'm hoping for substantial performance gain.
...
|
by: Donald Grove |
last post by:
I want to populate an array with values from an ado recordset
(multiple rows)
I use the absolute position of the cursor in the recordset to define
the row of my array to be populated. I have a workaround for lack of
a way to define the ordinal position of a field (incrementing a
counter variable), but it feels so primitive:
dim Fld as Field
dim rst1 as new adodb.recordset
|
by: mrmagoo |
last post by:
I'm building a vb.net Forms project that is getting data from a SQL Server
database.
One of the main goals of the project is to be really responsive to events,
such as textbox change events. I have a textbox for searching, a listbox to
display the searched results, and a big textbox (memo) to display the
clicked-results of the listbox item.
My question is: should I load the controls with objects, and therefore store
everything in...
|
by: rdemyan via AccessMonster.com |
last post by:
Can someone help me with creating code that will look for DAO recordsets in
modules and then check to see if the recordset is also closed in the module.
All of my recordsets are of the form rs* where * is a wildcard for letters
after rs.
Thanks.
--
Message posted via AccessMonster.com
|
by: BeckR |
last post by:
Hello - Thanks for reading my post.
I am a newbie when it comes to VBA programming, but have managed to do what I need to do, until now.
I have an Access 2000 database (running WinXP Pro (SP3)).
I have successfully created 3 recordsets in my database. What I need to do is to take the data from those 3 recordsets and put them into a table so that I can run reports at a later time. I was able to create the recordsets and the table with...
|
by: marktang |
last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look !
Part I. Meaning of...
| |
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it.
First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
|
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 protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
|
by: agi2029 |
last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own....
Now, this would greatly impact the work of software developers. The idea...
|
by: isladogs |
last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM).
In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules.
He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms.
Adolph will...
|
by: conductexam |
last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one.
At the time of converting from word file to html my equations which are in the word document file was convert into image.
Globals.ThisAddIn.Application.ActiveDocument.Select();...
|
by: adsilva |
last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
| |
by: 6302768590 |
last post by:
Hai team
i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
|
by: muto222 |
last post by:
How can i add a mobile payment intergratation into php mysql website.
| |