Send Debug output to table

  • Thread starter Thread starter Roger
  • Start date Start date
R

Roger

I have a few lines of vba that generate short debug output lines and then
creates a new database table.
Could anyone please advise how I can then send my lines of debug output into
a single field of this table so that they can be read and, if necessary,
printed later.
My vba knowledge is very basic so appreciate any help. TIA.

Roger
 
Roger said:
Could anyone please advise how I can then send my lines of debug
output into a single field of this table so that they can be read and,
if necessary, printed later.

There's no direct way. However, you can use the Eval function instead of
debug.print and send the output manually using either an append query or
DAO/ADO code to the row.

-- Dev
 
Roger said:
Could anyone please advise how I can then send my lines of debug
output into a single field of this table so that they can be read and,
if necessary, printed later.

Store them in strings: either in an array or a Collection.

Or else, if you can create the table first, you could send them straight to
the table without waiting.

HTH


Tim F
 
Tim Ferguson said:
Store them in strings: either in an array or a Collection.

Or else, if you can create the table first, you could send them straight to
the table without waiting.

Thanks for the replies Dev & Tim.
Just to clarify, my debug output is a string delimited by vbCr which I view
using print.debug mystring.
I have also managed to create an empty table with a single field for this
data.
All I need now is the vba code to send mystring to the new table. Any
advice greatly appreciated.

Roger
 
Roger said:
All I need now is the vba code to send mystring to the new table.

strSQL = "INSERT INTO DebugTable (LogText)" & vbNewLine & _
"VALUES (""" & strMyString & """);"

db.Execute strSQL, dbFailOnError


Note that if there are anyembedded quote marks in strMyString, they need to
be doubled up - use the Replace() function.

Hope that helps


Tim F
 
Tim Ferguson said:
strSQL = "INSERT INTO DebugTable (LogText)" & vbNewLine & _
"VALUES (""" & strMyString & """);"

db.Execute strSQL, dbFailOnError


Note that if there are anyembedded quote marks in strMyString, they need to
be doubled up - use the Replace() function.

Many thanks for the reply Tim - looks like it should resolve my problem
although I can't test it right now. If I still have problems I will repost
on this thread.

Cheers,

Roger
 
Back
Top