Kamis, 08 April 2021

Re: [MSAccessProfessionals] SQL

You can loop the recordset and either message box or debug.print the values.  This is my template code for a loop, with a debug. You can specify field names or use position as I did:

  Dim strSQL  As String
  Dim db      As DAO.Database
  Dim rs      As DAO.Recordset
  Set db = CurrentDb()
 
  strSQL = "SELECT...,"
  Set rs = db.OpenRecordset(strSQL, dbOpenDynaset)
  Do While Not rs.EOF
    Debug.Print rs(0), rs(1), ...
    rs.MoveNext
  Loop
  rs.Close
  set rs = nothing
  set db = nothing

Paul

------ Original Message ------
From: "Bill Singer" <Bill.Singer@at-group.net>
Sent: 4/8/2021 6:06:15 PM
Subject: [MSAccessProfessionals] SQL

In a Sub of Function, If I create a record set using SQL, is there anyway to actually view the results of the SQL Statement.  For example, if I try to pull 4 records, where can I see those 4 records?

 

Before I start to try to manipulate the records I would like to be able to know I am pulling the correct date.

 

Thanks,

Bill Singer

Access 365

 

Tidak ada komentar:

Posting Komentar