Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

how to "fix" a message box

Status
Not open for further replies.

bubba100

Technical User
Nov 16, 2001
493
US
I have a form that when a Close Form button is selected runs several checks on the information that was entered. From these checks an "exception" message box is generated that lists the records and the type of problem. This works as it should but at times there are so many "exceptions" that the message box extends past the right side of the monitor. Is there a way to have 20 (or any number of) exceptions listed then create a new line for the next group? The idea is to get the box to extend downward.

I would appreciate any ideas.

Here is some of the code used.

rst.FindFirst "Unit ='" & (Rstb!Unit) & "'"
If rst.NoMatch Then
Record = (Rstb!ID)
If Check2 = "" Then
Check2 = Record
Else
Check2 = Check2 & "," & Record
End If

Message2 = "The Following Records Have Unit Numbers Not Listed In The Equipment Table:" & Check2 & "."

If Check2 <> "" Then
Response = MsgBox(Message2, vbOKOnly)
If Response = vbOK Then Counter = 1
End If
 
I use a method of only listing one exception. The code runs through and stops at the first exception displaying a message box. I had tried putting them all together with carriage returns, but the users like this method as they don't have to remember as much.

John Green
 
In the code example below I concatenated a Carriage Return and Linefeed (constant: vbCRLF) instead of a comma.

Another possiblity would to use a counter and conditionally use vbCRLF if it was evenly divisible by some interval (i.e. IF Counter Mod 20 = 0 Then...)


Code:
rst.FindFirst "Unit ='" & (Rstb!Unit) & "'"
        If rst.NoMatch Then
        Record = (Rstb!ID)
        If Check2 = "" Then
            Check2 = Record
        Else
            Check2 = Check2 & vbCRLF & Record
        End If

Message2 = "The Following Records Have Unit Numbers Not Listed In The Equipment Table:" & Check2 & "."

If Check2 <> "" Then
    Response = MsgBox(Message2, vbOKOnly)
    If Response = vbOK Then Counter = 1
   End If

A different approach would be to open a modal form instead of a message box. Then it could display as many records in a scrollable format. Or switch to a report so the user can print it out.
 
You can put a carriage return/line feed after the record variable.
[tt]
Check2 = Check2 & "," & Record & vbCrLf
[/tt]
HTH,
Larry
 
Generally this is not a problem. I felt it might be one of those "will work on when things are slow" because there is no clear answer. Thanks.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top