Solved

Retrieving a single data item from a table

Posted on 2000-03-31
3
121 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
Comment Utility
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
Comment Utility
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
Comment Utility
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

Free Trending Threat Insights Every Day

Enhance your security with threat intelligence from the web. Get trending threat insights on hackers, exploits, and suspicious IP addresses delivered to your inbox with our free Cyber Daily.

Join & Write a Comment

I’ve seen a number of people looking for examples of how to access web services from VB6.  I’ve been using a test harness I built in VB6 (using many resources I found online) that I use for small projects to work out how to communicate with web serv…
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 utilization of class modules. Class modules can be a powerful tool in Microsoft Access. They allow you to create self-contained objects that encapsulate functionality. They can easily hide the complexity of a process from…
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…

728 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

9 Experts available now in Live!

Get 1:1 Help Now