dbTalk Databases Forums  

Fastest way to browse recordset?

comp.databases.ms-access comp.databases.ms-access


Discuss Fastest way to browse recordset? in the comp.databases.ms-access forum.



Reply
 
Thread Tools Display Modes
  #1  
Old   
David
 
Posts: n/a

Default Fastest way to browse recordset? - 12-15-2004 , 02:33 PM






When I am programming, I want to view recordsets that I've created on
the fly. I open them with something like:

set tTable = CurrentDb.OpenRecordSet("select fRecNo,fDesc from
tDrivers")

If I executed this line, and interupted the program, what is the
fastest way to view the resulting recordset to make sure things look
all right?

David


Reply With Quote
  #2  
Old   
Bas Cost Budde
 
Posts: n/a

Default Re: Fastest way to browse recordset? - 12-15-2004 , 03:28 PM






David wrote:
Quote:
When I am programming, I want to view recordsets that I've created on
the fly. I open them with something like:

set tTable = CurrentDb.OpenRecordSet("select fRecNo,fDesc from
tDrivers")

If I executed this line, and interupted the program, what is the
fastest way to view the resulting recordset to make sure things look
all right?
dumprs ttable

Sub dumpRs(rs As Recordset)
Dim cBook As String
If rs.RecordCount = 0 Then
Debug.Print "empty."
Else
cBook = rs.Bookmark
rs.MoveFirst
dumpRecord rs, True
Do Until rs.EOF
dumpRecord rs
rs.MoveNext
Loop
Debug.Print
rs.Bookmark = cBook
End If
End Sub

Sub dumpRecord(rs As Recordset, Optional fieldnames = False)
Dim fd As Field
For Each fd In rs.Fields
If fd.OrdinalPosition > 0 Then Debug.Print ", ";
If fieldnames Then
Debug.Print fd.Name;
Else
Debug.Print fd.Value;
End If
Next
Debug.Print
End Sub



--
Bas Cost Budde, Holland
http://www.heuveltop.nl/BasCB/msac_index.html
I prefer human mail above automated so in my address
replace the queue with a tea


Reply With Quote
  #3  
Old   
Tim Marshall
 
Posts: n/a

Default Re: Fastest way to browse recordset? - 12-17-2004 , 07:50 AM



David wrote:

Quote:
When I am programming, I want to view recordsets that I've created on
the fly. I open them with something like:

set tTable = CurrentDb.OpenRecordSet("select fRecNo,fDesc from
tDrivers")

If I executed this line, and interupted the program, what is the
fastest way to view the resulting recordset to make sure things look
all right?
Define the sql with a string variable and do a debug.print on the string
before executing the above. Cut the statement from the debug window,
paste into an SQL view of a query and voila!

Sounds involved, but I do this all the time and it works fine.

--
Tim http://www.ucs.mun.ca/~tmarshal/
^o<
/#) "Burp-beep, burp-beep, burp-beep?" - Quaker Jake
/^^ "What's UP, Dittoooooo?" - Ditto


Reply With Quote
  #4  
Old   
Bas Cost Budde
 
Posts: n/a

Default Re: Fastest way to browse recordset? - 12-17-2004 , 08:19 AM



Tim Marshall wrote:
Quote:
David wrote:

When I am programming, I want to view recordsets that I've created on
the fly. I open them with something like:

set tTable = CurrentDb.OpenRecordSet("select fRecNo,fDesc from
tDrivers")

If I executed this line, and interupted the program, what is the
fastest way to view the resulting recordset to make sure things look
all right?


Define the sql with a string variable and do a debug.print on the string
before executing the above. Cut the statement from the debug window,
paste into an SQL view of a query and voila!

Sounds involved, but I do this all the time and it works fine.
I do that all the time too, and I find it so boring that I wrote a small
helper routine:

Sub Q(Optional cSQL = "")
Dim qd As QueryDef
On Error Resume Next
DoCmd.Close acQuery, "_temp", acSaveNo
Set qd = CurrentDb.QueryDefs("_temp")
qd.SQL = cSQL
DoCmd.OpenQuery qd.Name, acViewDesign
End Sub

I have a query called _temp for this purpose. Now, from the debug
window, I can type

q <variable>

and I will get the query in design view. More Voila!


--
Bas Cost Budde, Holland
http://www.heuveltop.nl/BasCB/msac_index.html
I prefer human mail above automated so in my address
replace the queue with a tea


Reply With Quote
  #5  
Old   
Salad
 
Posts: n/a

Default Re: Fastest way to browse recordset? - 12-17-2004 , 09:07 AM



David wrote:
Quote:
When I am programming, I want to view recordsets that I've created on
the fly. I open them with something like:

set tTable = CurrentDb.OpenRecordSet("select fRecNo,fDesc from
tDrivers")

If I executed this line, and interupted the program, what is the
fastest way to view the resulting recordset to make sure things look
all right?

David

'here is a way to pass a SQL string to a proc to display the results.
'the ShowResults sub calls DisplayResults and presents the data in
datasheet view. If JunkQuery exists, it gets deleted. A new query is
then created called JunkQuery. The result records are displayed.

Sub ShowResults()
DisplayResults "Select * From Table"
End Sub

Sub DisplayResults(strSQL As String)

Dim dbs As Database
Dim qdfNew As QueryDef

Set dbs = CurrentDb

On Error Resume Next
DoCmd.DeleteObject acQuery, "JunkQuery"

Set qdfNew = dbs.CreateQueryDef("JunkQuery", strSQL)

DoCmd.OpenQuery "JunkQuery"

End Sub



Reply With Quote
  #6  
Old   
Bas Cost Budde
 
Posts: n/a

Default Re: Fastest way to browse recordset? - 12-17-2004 , 10:09 AM



Aha, you too ;-)

--
Bas Cost Budde, Holland
http://www.heuveltop.nl/BasCB/msac_index.html
I prefer human mail above automated so in my address
replace the queue with a tea

Reply With Quote
  #7  
Old   
Salad
 
Posts: n/a

Default Re: Fastest way to browse recordset? - 12-18-2004 , 04:55 AM



Bas Cost Budde wrote:
Quote:
Aha, you too ;-)
Great minds think alike. :-)


Reply With Quote
Reply




Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off



Powered by vBulletin Version 3.5.3
Copyright ©2000 - 2012, Jelsoft Enterprises Ltd.