Expiring Today—Celebrate National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

Retrieving a single data item from a table

Posted on 2000-03-31
3
Medium Priority
?
127 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
3 Comments
 
LVL 14

Accepted Solution

by:
wsh2 earned 200 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

Concerto Cloud for Software Providers & ISVs

Can Concerto Cloud Services help you focus on evolving your application offerings, while delivering the best cloud experience to your customers? From DevOps to revenue models and customer support, the answer is yes!

Learn how Concerto can help you.

Question has a verified solution.

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

If you have ever used Microsoft Word then you know that it has a good spell checker and it may have occurred to you that the ability to check spelling might be a nice piece of functionality to add to certain applications of yours. Well the code that…
When designing a form there are several BorderStyles to choose from, all of which can be classified as either 'Fixed' or 'Sizable' and I'd guess that 'Fixed Single' or one of the other fixed types is the most popular choice. I assume it's the most p…
Show developers how to use a criteria form to limit the data that appears on an Access report. It is a common requirement that users can specify the criteria for a report at runtime. The easiest way to accomplish this is using a criteria form that a…
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…
Suggested Courses

719 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