Solved

Retrieving a single data item from a table

Posted on 2000-03-31
3
122 Views
Last Modified: 2010-05-02
I would like to runa  simple select statement:

BooksConnection.Execute "SELECT LineOfText FROM ImportCheck WHERE ProviderID = " & ProviderID & " AND LineNumber = " & Counter

This works. How do I place that one data item (LineOfText) into a variable so I can use it? Does it go into some default recordset? I am not getting an error and I use many SQL statements in my code now for Inserts and deletes

Thanks
                                 
0
Comment
Question by:scotts27
  • 2
3 Comments
 
LVL 14

Accepted Solution

by:
wsh2 earned 50 total points
ID: 2673754
dim rs as adodb.recordset

set rs = BooksConnection.Execute "SELECT LineOfText FROM ImportCheck WHERE ProviderID = " & ProviderID & " AND LineNumber = " & Counter

Do Until rs.EOF
  MyVar = rs!LineOfText
  rs.MoveNext
Loop
0
 

Author Comment

by:scotts27
ID: 2674124
I tried this as wriiten and VB give me an error on the set rs = line. It says "Expected End of Statement" I simplified it to the most basic select statement and I still get this.

I have worked around it defining the record set and the select statement and using and rs.cursurlocation and an rs.open statement.

I would like to get it working the way wsh2 suggests if possible. It is much simpler and easier to read.  thanks
0
 
LVL 14

Expert Comment

by:wsh2
ID: 2674197
Simplke fix to the design time error message.. Change this statement

From:

set rs = BooksConnection.Execute "SELECT LineOfText FROM ImportCheck WHERE ProviderID = " & ProviderID & " AND LineNumber = " & Counter

To:

set rs = BooksConnection.Execute ("SELECT LineOfText FROM ImportCheck WHERE ProviderID = " & ProviderID & " AND LineNumber = " & Counter)

ie. just put parenthesis around your query).. <smile>.
0

Featured Post

Announcing the Most Valuable Experts of 2016

MVEs are more concerned with the satisfaction of those they help than with the considerable points they can earn. They are the types of people you feel privileged to call colleagues. Join us in honoring this amazing group of Experts.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Introduction I needed to skip over some file processing within a For...Next loop in some old production code and wished that VB (classic) had a statement that would drop down to the end of the current iteration, bypassing the statements that were c…
When trying to find the cause of a problem in VBA or VB6 it's often valuable to know what procedures were executed prior to the error. You can use the Call Stack for that but it is often inadequate because it may show procedures you aren't intereste…
Get people started with the process of using Access VBA to control Outlook using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Microsoft Outlook. Using automation, an Access applic…
This lesson covers basic error handling code in Microsoft Excel using VBA. This is the first lesson in a 3-part series that uses code to loop through an Excel spreadsheet in VBA and then fix errors, taking advantage of error handling code. This l…

813 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

11 Experts available now in Live!

Get 1:1 Help Now