Flummoxed by malformed MsgBox: HELP!

A

Abe Hendin

I'm completely flummoxed (baffled) by the fact that the MsgBox marked
below simply refuses to display the buttons and icon I call for. All I
get is OK, which breaks the functionality. I've tried republishing the
form, clearing the cache, and changing the icon and button calls, but
both MsgBoxes in this sub just don't respond. I don't see anything wrong
with the syntax, but wouldn't mind the obvious being pointed out. :-|

Any ideas? Thanks!

Abe

--------
My code:

Sub cmdReloadFromDataRepository_Click()
strCurrSec = Item.UserProperties("StudentClassSection").Value
If Not strCurrSec = "None" Then
'BAD MSGBOX FOLLOWS: DISPLAYS NO ICON, AND OK ONLY
intR = MsgBox("You are about to update the charges listed on the
Payment Setup " & _
Chr(13) & "and Payment Details tabs. No changes will be made to
the " & _
Chr(13) & "amounts paid, but the amounts due will be updated to
reflect " & _
Chr(13) & "changed charges." & _
Chr(13) & Chr(13) & "This action cannot be undone. Continue?", _
vbYesNoCancel & vbExclamation, _
"Reload charges?")
If intR = vbYes Then
intR = MsgBox("Apply change to all members of " & strCurrSec &
"?" & _
Chr(13) & Chr(13) & "YES: Update entire class; NO: Update just
this student." & _
"This action cannot be undone. Continue?", _
vbYesNoCancel & vbExclamation, _
"Apply update to entire class?")

If intR = vbYes Then 'do all class members
Set objCurrFolder = Item.Parent
Set objAllItems = objCurrFolder.Items
strFilter = "[StudentClassSection] = " & Chr(34) & strCurrSec &
Chr(34)
Set objClassMembers = objAllItems.Restrict(strFilter)
For Each Item In objClassMembers
Call SetUpPaymentDetails
Item.Save
Next
Set objCurrFolder = Nothing
Set objAllItems = Nothing
Set objClassMembers = Nothing
ElseIf intR = vbNo Then 'just do current student
Call SetUpPaymentDetails
End If
End If
Else
intR = MsgBox("You may update charges only with class members!", _
vbOKOnly & vbCritical, _
"Invalid item")
End If
End Sub
 
A

Abe Hendin

Abe said:
vbYesNoCancel & vbExclamation, _

Finally realized that the "&" is the confounded culprit. In another
language I work in frequently, there is no difference between "&" and
"+" in a similar context. Clearly, VB and VBScript want "+" only here.

Abe
 
L

LGriffith

-----Original Message-----



Finally realized that the "&" is the confounded culprit. In another
language I work in frequently, there is no difference between "&" and
"+" in a similar context. Clearly, VB and VBScript want "+" only here.

Abe

.
Abe,

There is a simpler way to get the same thing, with less
typing. The easiest way to get the value for the BUTTONS
argumentis to use the sum of three numbers:

BUTTONTYPES + ICON + DEFAULTBUTTON

Each of the values is a Visual Basic Constant.

The BUTTONTYPES constants:
vbOkOnly = 0
vbOKCancel = 1
vbAbortRetryIgnore = 2
vbYesNoCancel = 3
vbYesNo = 4
vbRetryCancel = 5

ICON constants:
vbCritical = 16
vbQuestion = 32
vbExclamation = 48
vbInformation = 64

DEFAULTBUTTON constants:
vbDefaultButton1 = 0
vbDefaultButton2 = 256
vbDefaultButton3 = 512

So, instead of using "vbYesNoCancel + vbExclamation", it
would read...

Values from table:
vbYesNoCancel = 3
vbExclamation = 48

Add the values:
3 + 48 = 51

Use sum of needed constants:
MsgBox "This action cannot be undone. Continue?", _
51, "Reload charges?"
 
A

Abe Hendin

LGriffith said:
There is a simpler way to get the same thing, with less
typing. The easiest way to get the value for the BUTTONS
argumentis to use the sum of three numbers:

BUTTONTYPES + ICON + DEFAULTBUTTON

Hi, LGriffith. I do know of this method, but long ago I realized that
the verbose constants are much easier to work with further on, after
I've put a project to bed for a while, since there's no way in He** that
I'd be able to remember the various sums ;-), and I don't want to have
to consult a chart.

Thanks anyway,

Abe
 
A

Abe Hendin

Sue said:
You don't really need to remember the various sums -- just add the different constants together.

Hi, Sue. It's the reverse I have trouble with: working out which options
I used from the total I see 3 months after a finished a msgbox... I just
prefer verbose constants. It makes it much easier for me to review my
code, when I'm just reading through it on paper or on-screen.

Abe
 
S

Sue Mosher [MVP]

Constants definitely are the way to go.

Abe Hendin said:
Hi, Sue. It's the reverse I have trouble with: working out which options
I used from the total I see 3 months after a finished a msgbox... I just
prefer verbose constants. It makes it much easier for me to review my
code, when I'm just reading through it on paper or on-screen.

Abe
 

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