Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

Retrieving a single data item from a table

Posted on 2000-03-31
3
Medium Priority
?
128 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 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

What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

Question has a verified solution.

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

Background What I'm presenting in this article is the result of 2 conditions in my work area: We have a SQL Server production environment but no development or test environment; andWe have an MS Access front end using tables in SQL Server but we a…
I was working on a PowerPoint add-in the other day and a client asked me "can you implement a feature which processes a chart when it's pasted into a slide from another deck?". It got me wondering how to hook into built-in ribbon events in Office.
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…
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…
Suggested Courses

916 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