Results 1 to 3 of 3

Thread: List a record in the debug/immediate window

  1. #1

    Thread Starter
    New Member
    Join Date
    Jun 2005
    Posts
    11

    List a record in the debug/immediate window

    How would I go about listing a record in the immediate window, ie

    If i had a table called tblCustomer, with 3 fields, customerID, Firstname and lastname

    CustomerID Firstname LastName
    1 Debbie Smith
    2 Mark Jones
    3 Nora Batty

    if i said "Select * from tblCustomer where Customer ID = 1" What I want is to be able to produce a list int he debug window to check the values (its just something I am playing with)

    This is what I want the results to be

    CustomerID: 1
    Firstname: Debbie
    LastName Smith

    any help appreciated.

    Debbie

  2. #2
    Frenzied Member
    Join Date
    May 2004
    Location
    Carlisle, PA
    Posts
    1,045

    Re: List a record in the debug/immediate window

    Debbie:
    =====
    I'm a NEWBIE, but this worked for my. You must have "Microsoft ActiveX Data Objects" included in your references (Library List) for this to work. You'll just have to insert your own names and mung with the "Debug.Print" statements. This is working code that I tested this morning.
    Code:
    ' Create an ADODB RecordSet from a Table in the Current Database
    Sub ADO_RST()
    'From MS Access Programmer's Handbook
    'http://msdn.microsoft.com/library/default.asp?url=/library/en-us/odeopg/html/deovropeningaccessdatabasebyusingado.asp
        Dim myCon As ADODB.Connection
        Dim myRST As ADODB.Recordset
        Dim mySQL As String
        
        'Define the Query for the RecordSet data from the table
        mySQL = "SELECT * FROM TEST_EXTRACT"
        
        'Test "New" keyword HERE
        Set myCon = New ADODB.Connection
        'Define the intrinsic connection to the current database
        Set myCon = CurrentProject.Connection
        Debug.Print myCon.ConnectionString  'This is what it looks like
        'Create the RecordSet for the data from the table and open it
        Set myRST = New ADODB.Recordset
        myRST.Open mySQL, myCon, adOpenForwardOnly, adLockReadOnly
        'Scan and look at the Recordset data from my table
        With myRST
        While Not .EOF
            Debug.Print .Fields(0), .Fields(1), .Fields(2), .Fields(3)
            .MoveNext
        Wend
        End With
        
        'Clean House
        myRST.Close
        Set myRST = Nothing
        'myCon.Close  < Don't close the intrinsic connection
        Set myCon = Nothing
    End Sub
    Good Luck and Good Learning!
    Blessings in abundance,
    All the Best,
    & ENJOY!

    Art . . . . Carlisle, PA . . USA

  3. #3
    Fanatic Member dannymking's Avatar
    Join Date
    Jul 2005
    Location
    Darlington, North East UK
    Posts
    677

    Re: List a record in the debug/immediate window

    With the Access 97 Developer's handbook there was an addin written called SQL Scratchpad that would do this for you...Chapter 5 (it's also on the CD)

    All you would need to do is type in your SQL and it will show some of the values to be returned..

    If you've got the book then sorted, if not try and get hold of an old one
    Danny

    Never Think Impossible

    If you find my answer helpful then please add to my reputation

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width