MsgBox Function

  • Thread starter Thread starter Joe Williams
  • Start date Start date
J

Joe Williams

how do I create a MsgBox that displays multiple lines of data? For example,
I want to run a validation routine that will show the user the errors on
thier form when a button is pressed. It could be only one error, it could be
more than that. I would like the MsgBox to display the errors on separate
lines, as follows:

Date field cannot be left blank
User ID must be entered
Quantity must be greater than 0

I know how to send a string to the MsgBox function, but not how to make the
MsgBox grow dynamically with a separate line for each error. Any thoughts?

Thanks!

-joe
 
do something like this (assumes error messages are stored in string
variables):

txtError1 & vbCRLF & txtError2 & vbCRLF & txtError3

if you get a blank line when an error is not selected, try this:

txtError1 + vbCRLF & txtError2 + vbCRLF & txtError3
 
how do I create a MsgBox that displays multiple lines of data? For example,
I want to run a validation routine that will show the user the errors on
thier form when a button is pressed. It could be only one error, it could be
more than that. I would like the MsgBox to display the errors on separate
lines, as follows:

Date field cannot be left blank
User ID must be entered
Quantity must be greater than 0

I know how to send a string to the MsgBox function, but not how to make the
MsgBox grow dynamically with a separate line for each error. Any thoughts?

Thanks!

-joe

As I can't see your database, the best I can do for you is some
generic information.

Dim strMessage as String
strMessage = IIf(IsNull([DateField]),"Date field cannot be left
blank." & vbNewLine,IIf(IsNull([UserID]),"User ID must be entered." &
vbNewLine,IIf([Quantity]<=0,"Quantity must be greater than 0","")))

MsgBox "You have incorrect entries " & vbNewLine & strMessage
 
Back
Top