Debug.print ?

M

Mark

First let me give the create to Luke Chung for this code.

I was checking out this website (http://www.fmsinc.com/tpapers/queries/)
when I saw this code and I wanted to use it. The question I have is on the…

…Debug.Print part. He said it would display in the immediate window. Is
there a way to have this print on a form, or a component within a form, i.e.
listbox, text fields, etc.? If so, how? If not, what? Thanks

Private Sub RecordSetQuery ()
Const strQueryName = "Other: Top 10 Auto Companies"
Dim db As Database
Dim rs As Recordset
Set db = CurrentDB() ' Open pointer to current database
Set rs = db.OpenRecordset(strQueryName) ' Open recordset on saved query
Do While Not rs.eof
Debug.Print ("Company: " & rs![Company] & " Sales: " & rs![1994])
rs.MoveNext
Loop
rs.Close
db.Close
End Sub
 
M

Mark

Okay, I fill like a goober now. I did a little more checking and this is
used during debug (Duh) .
Question: How would I use that code (minus the debug.print) and have it
displayed to a form?
 
D

Douglas J. Steele

If you've got a text box named txtResults on your form, you can change that
from

Debug.Print ("Company: " & rs![Company] & " Sales: " & rs![1994])

to

Me.txtResults = Me.txtResults & "Company: " & rs![Company] & " Sales: " &
rs![1994]) & vbCrLf
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top