473,386 Members | 1,715 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,386 software developers and data experts.

Why does this query fail in ADODB.recordset?

157 100+
I have query this to filter the posts i want to work with, it is called "MAIN ompakkingskø baklager Gemba" and the sql is this:

Expand|Select|Wrap|Line Numbers
  1. SELECT [LOK Loksummer].Varenr, [LOK Loksummer].Lokasjon AS Baklager, [LOK Loksummer].[Antall tabletter], Left([lokasjon],2) AS c
  2. FROM [LOK Loksummer]
  3. WHERE ((([LOK Loksummer].Lokasjon) Like "*Gemba*") AND ((Left([lokasjon],2))="01" Or (Left([lokasjon],2))="02" Or (Left([lokasjon],2))="03" Or (Left([lokasjon],2))="04" Or (Left([lokasjon],2))="05" Or (Left([lokasjon],2))="06" Or (Left([lokasjon],2))="07" Or (Left([lokasjon],2))="08" Or (Left([lokasjon],2))="09" Or (Left([lokasjon],2))="10" Or (Left([lokasjon],2))="11" Or (Left([lokasjon],2))="12" Or (Left([lokasjon],2))="13" Or (Left([lokasjon],2))="14" Or (Left([lokasjon],2))="15" Or (Left([lokasjon],2))="16" Or (Left([lokasjon],2))="17" Or (Left([lokasjon],2))="18"));
I always use ADODB.recordset to work with data. Either to insert data in forms or in tables.

When i open the query by clicking on the query it shows exactly the post it is supposed to show, but when i open it with ADODB it gives an error

Expand|Select|Wrap|Line Numbers
  1. Dim rst As New ADODB.Recordset
  2. With rst
  3.     .Open "MAIN ompakkingskø baklager Gemba", CurrentProject.Connection, adOpenForwardOnly, adLockReadOnly
  4.         Do Until .EOF
  5.         MsgBox !baklager
  6.         .MoveNext
  7.         Loop
  8.     .Close
  9. End With
  10. Set rst = Nothing
This DAO is working fine:
Expand|Select|Wrap|Line Numbers
  1. Dim rs As dao.Recordset
  2.  
  3. Set rs = CurrentDb.OpenRecordset("MAIN ompakkingskø baklager Gemba")
  4. While Not rs.EOF
  5. MsgBox rs!baklager
  6. rs.MoveNext
  7. Wend
  8. rs.Close
  9. Set rs = Nothing
  10.  
Jul 24 '09 #1
1 2462
ADezii
8,834 Expert 8TB
@MrDeej
Try a change in Syntax, and see what happens:
Expand|Select|Wrap|Line Numbers
  1. Dim rst As New ADODB.Recordset
  2.  
  3. With rst
  4.   .Source = "MAIN ompakkingskø baklager Gemba"
  5.   .ActiveConnection = CurrentProject.Connection
  6.   .CursorType = adOpenForwardOnly
  7.   .LockType = adLockReadOnly
  8.     .Open
  9.  
  10.   Do While Not .EOF
  11.     MsgBox !baklager
  12.       .MoveNext
  13.   Loop
  14. End With
  15.  
  16. rst.Close
  17. Set rst = Nothing
What is the Error you are receiving if the previous does not work?

You should also consider modifying part of your WHERE Clause:
Expand|Select|Wrap|Line Numbers
  1. AND Left$([Lokasjon],2) In ("01","02","03","04","05","06","07","08","09","10","11","12","13","14","15","16","17","18")
Jul 24 '09 #2

Sign in to post your reply or Sign up for a free account.

Similar topics

5
by: BP | last post by:
I get the following error: Error Type: Microsoft VBScript runtime (0x800A01A8) Object required: '' /myweb4/authorised_user_page.asp, line 70 and line 70 of my code is: <% rsCheckUser1.Open...
9
by: shank | last post by:
Per a previous suggestion, I'm trying to use a parametized query in Access 2002. The query functions properly in Access. Now I'm trying to call it from ASP. I'm using code I found at...
2
by: Auddog | last post by:
I have created a database request page (wahooo - new to asp and it works) and everything is great. Now I'm creating a second page and want to know if I'm able to make two different queries on one...
2
by: David C. Barber | last post by:
upsized an MDB to ADP/SQL Server 2000 under Access 2000. All the DAO code that I've changed to ADO code is working fine, HOWEVER the form Record Source itself does not seem willing to return data....
0
by: totierne | last post by:
comp.databases.ms-access, I want to know how to use Oracle views with session variables in Access. The parameterised views in access, are migrated to views with per session variables. The...
2
by: barret bonden | last post by:
(closest newsgroup I could find) Error Type: ADODB.Recordset (0x800A0CB3) Current Recordset does not support updating. This may be a limitation of the provider, or of the selected locktype....
5
by: Hexman | last post by:
I've come up with an error which the solution eludes me. I get the error: >An unhandled exception of type 'System.Runtime.InteropServices.COMException' occurred in HRTest.exe > >Additional...
1
by: Mayhem05 | last post by:
I have an Access 2003 database that I need to write some VBA code for to populate a table. The table is based on a query I have built in Access queries. Right now I have 2 parameters that are...
0
by: SMasterson | last post by:
Hi all, I am trying to execute code to insert records from an Access 2002 Xtab query to a remote Sql_Server table. I keep getting a random problem where the Access query doesn't complete before the...
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
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: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
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:
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
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...

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.