1

I am writting a test code in access 2007 (VBA) that would test the data and report if any record has problem. It would do it by checking data with external data, so I am not using any of the access reporting tools.

This is an internal tools and will be used only by me, so the UI is not that important.

What I am doing is to write a VBA code that read recordset and external data and check the recordset.

I can do this, but I need a way to print this on UI. Something such as this:

Record no 10 is not valid : reason XXXX

Record 15 is not valid: reason YYYY

I was thinking of using a multi line text box to output this on screen, but I have several problem:

  1. I can not find any way to make a text box as a multi line text box. There is no multi line propertyso I can output a line break.
  2. If the size of recordset is big and there are a lot of errors, I am getting error that the size pro text proprty is too big.

What control should I use? I was thinking about using a label control, but I'm not sure if it's possible.

Community
  • 1
  • 1
mans
  • 17,104
  • 45
  • 172
  • 321

2 Answers2

0

The UserForm control in VBA has a MultiLine property, which you can set to True.

The other property is the EnterKeyBehavior that needs to be set to True to allow line breaks.

Alternately yes, you could use a Label control to achieve the same and even format it to look like a TextBox if you care.

But if long string of data, I would consider outputing it straight to a file with Open and For Output or For Append.

ib11
  • 2,530
  • 3
  • 22
  • 55
0

The easiest way is to use Debug.Print (output goes to the Immediate window -> Ctrl+g).

An Access text box that is large enough is always multi-line capable, there is no special property for that. Just append vbCrLf to each line to create a line break.

Me.txtLog = Me.txtLog & strError & vbCrLf

But for really long text output, a log file is the best option.

To write text files: either use FileSystemObject or the old fashioned Open statement.

Community
  • 1
  • 1
Andre
  • 26,751
  • 7
  • 36
  • 80