473,466 Members | 1,320 Online
Bytes | Software Development & Data Engineering Community
Create Post

Home Posts Topics Members FAQ

query works in querybuilder, not in VB

I'm trying to create a adodb recordset in an Access Module for updating
but when I try to open it it returns EOF. However, I can cut and past
the sql into QueryBuilder it returns the record. At a complete loss on
this one.

VB Code:
Dim prst As New ADODB.Recordset

prst.Open "Select Inventory.InvNo, Inventory.Receiptdate,
Inventory.ReceiptNo, Inventory.Item, Inventory.CurrentItemCost,
Inventory.Qty, Inventory.ShipDetailNos, Inventory.Location,
Inventory.SerialNumber from Inventory where ShipDetailNos Like '*:" &
Str(intNo) & ":*'", CurrentProject.Connection, adOpenDynamic,
adLockOptimistic

Nov 13 '05 #1
6 2154
On 20 Oct 2005 07:25:10 -0700, wy*****@gmail.com wrote:
I'm trying to create a adodb recordset in an Access Module for updating
but when I try to open it it returns EOF. However, I can cut and past
the sql into QueryBuilder it returns the record. At a complete loss on
this one.

VB Code:
Dim prst As New ADODB.Recordset

prst.Open "Select Inventory.InvNo, Inventory.Receiptdate,
Inventory.ReceiptNo, Inventory.Item, Inventory.CurrentItemCost,
Inventory.Qty, Inventory.ShipDetailNos, Inventory.Location,
Inventory.SerialNumber from Inventory where ShipDetailNos Like '*:" &
Str(intNo) & ":*'", CurrentProject.Connection, adOpenDynamic,
adLockOptimistic


By default, JET uses different wildcard characters in ADO than in DAO. In
ADO, it uses the ANSI characters for wildcards. I believe it is "%" and "_"
instead of "*" and "?".

When I'm using the query builder for a query that will be executed using ADO,
I try to always use the "ALike" keyword instead of "Like". "ALike" means
ANSI-Like, and it always follows the ANSI rules. Using ALike, you only use
the ANSI wildcards regardless of settings or database library, so what you do
in the builder will still be right in the SQL srting passed to ADO.
Nov 13 '05 #2
Just tried

prst.Open "Select [snip] from Inventory where ShipDetailNos ALike '%:"
& Str(intNo) & ":%'", CurrentProject.Connection

and

prst.Open "Select [snip] from Inventory where ShipDetailNos ALike '*:"
& Str(intNo) & ":*'", CurrentProject.Connection

and still no go.

Nov 13 '05 #3
On 20 Oct 2005 07:38:57 -0700, wy*****@gmail.com wrote:
Just tried

prst.Open "Select [snip] from Inventory where ShipDetailNos ALike '%:"
& Str(intNo) & ":%'", CurrentProject.Connection
With or without ALike, that should have worked in ADO. I can't say why it
wouldn't.

and

prst.Open "Select [snip] from Inventory where ShipDetailNos ALike '*:"
& Str(intNo) & ":*'", CurrentProject.Connection

and still no go.


The "*" wildcard will -never- work with ALike, so that's no surprise.
Nov 13 '05 #4
bear in mind I'm doing this within an Access form, not in a Vb front
end. I use * within Access forms for wildcard, even with ADO, and it
works fine. i've been stumped on this one for going on 6 hours now.
Tried changing everything around (lock type, * vrs files, etc) and
still it's crapping out. Unfortunately it's part of a critical process
I have to have completed by Monday morning.

Nov 13 '05 #5
On 20 Oct 2005 07:55:13 -0700, wy*****@gmail.com wrote:
bear in mind I'm doing this within an Access form, not in a Vb front
end. I use * within Access forms for wildcard, even with ADO, and it
works fine. i've been stumped on this one for going on 6 hours now.
Unless you're using an ADP front-end to SQL Server, that's not a meaningful
thing to say. Access seems to sort of talk to JET through DAO, and sort of
around behind it, and does not use ADO. In any case, searching within a form
is using the Access user interface to cycle through the opern records, and
find the record - it's not using a Where clause in a database query.
Tried changing everything around (lock type, * vrs files, etc) and
still it's crapping out. Unfortunately it's part of a critical process
I have to have completed by Monday morning.


In what way is it crapping out?
Nov 13 '05 #6
You might try storing your SQL string to a separate variable first.
You can then evaluate that string, and cut and paste it into the Query
Builder.
You may find that what you have isn't exactly what you thought you had...

For example, Str() returns a string which starts with a space, which may not
be exactly what you want here. You could consider using CStr() if you don't
want that space...

<wy*****@gmail.com> wrote in message
news:11********************@g44g2000cwa.googlegrou ps.com...
I'm trying to create a adodb recordset in an Access Module for updating
but when I try to open it it returns EOF. However, I can cut and past
the sql into QueryBuilder it returns the record. At a complete loss on
this one.

VB Code:
Dim prst As New ADODB.Recordset

prst.Open "Select Inventory.InvNo, Inventory.Receiptdate,
Inventory.ReceiptNo, Inventory.Item, Inventory.CurrentItemCost,
Inventory.Qty, Inventory.ShipDetailNos, Inventory.Location,
Inventory.SerialNumber from Inventory where ShipDetailNos Like '*:" &
Str(intNo) & ":*'", CurrentProject.Connection, adOpenDynamic,
adLockOptimistic

Nov 13 '05 #7

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

Similar topics

0
by: Sean | last post by:
I have a MySQL 4.1.11 database, table and table columns all configured as utf8 as I need to accept data in a number of languages. The MySQL database is hosted so I use SET NAMES utf8 in the...
2
by: Willem | last post by:
Hi there, I'm sort of new with doing much record manipulation with queries. Up till now I've been programming VBA and doing record looping to get my results. This works fine but tends to get...
7
by: K. Crothers | last post by:
I administer a mechanical engineering database. I need to build a query which uses the results from a subquery as its input or criterion. I am attempting to find all of the component parts of...
2
by: Ben de Vette | last post by:
Hi, I'm using the querybuilder when updating a record in a table (Access). However, I get a "Query is too complex" message. The Primary key is autonumbered. Why is it making such a complex...
36
by: Liam.M | last post by:
hey guys, I have one last problem to fix, and then my database is essentially done...I would therefore very much appreciate any assistance anyone would be able to provide me with. Currently I...
2
by: googlegroups.dsbl | last post by:
I'm really confused here, and am wondering if someone knows what could be the issue with my TableAdapter query. A few months ago, I created a really neat program that has th ability to search by...
1
by: Phil | last post by:
Is it possible to swap rows and columns in select query output so that each record's data is displayed in a column? I want to collect data each day and display it in a query with each day's date...
6
by: john | last post by:
I'm trying to do something that I thought was simple but has already taken me hours. I'm trying to use a value from an unbound date field in a query. Amongst others I tried the following, but I...
4
by: jameswilkinsonfjs | last post by:
Hi All, Ok I have a table - it lists items with a unique reference code; lets say there are 4 items : Item RefCode 1 ABC1 2 ABC2 3 ...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
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,...
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
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
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...
0
isladogs
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...
0
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...
0
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 ...

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.