MsgBox Function

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
 
R

Roger Carlson

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
 
F

fredg

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
 

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