MsgBox Help

D

DRMOB

I am having difficulty getting this right. When I put a check in Waive10%
I'd like to have a message appear asking "Are you sure you want to Waive the
10%?", If you choose yes the check remains, if you choose No, the check does
not remain. Also, if you uncheck Waive% you should get a message "You will
NOT be waiving the 10%" If you choose OK the check does not remain, if you
choose Cancel, the check will remain. The following only half works, it does
not give me the Yes/No option or the OK/Cancel option. Any help is greatly
appreciated.

Private Sub Waive10__BeforeUpdate(Cancel As Integer)
If Me![Waive10%] = True Then
Yes = True
No = False
MsgBox "You are waiving the 10%."
ElseIf Me![Waive10%] = False Then
OK = True
Cancel = False
MsgBox "You will not be waiving the 10%"

End If
End Sub
 
A

Arvin Meyer [MVP]

Try this (aircode):

Private Sub Waive10__AfterUpdate()
If Me![Waive10%] = True Then
If MsgBox("You are waiving the 10%.", vbYesNo = vbNo Then
Me.[Wave10%] = False
MsgBox "You will not be waiving the 10%", vbOKOnly
End If
End If
End Sub
 
D

Douglas J. Steele

Unfortunately, Arvin put a little too much air there. <g> (He's missing a
closing parenthesis in the first MsgBox statement)

Private Sub Waive10__AfterUpdate()
If Me![Waive10%] = True Then
If MsgBox("You are waiving the 10%.", vbYesNo) = vbNo Then
Me.[Wave10%] = False
MsgBox "You will not be waiving the 10%", vbOKOnly
End If
End If
End Sub


--
Doug Steele, Microsoft Access MVP

(no e-mails, please!)


Arvin Meyer said:
Try this (aircode):

Private Sub Waive10__AfterUpdate()
If Me![Waive10%] = True Then
If MsgBox("You are waiving the 10%.", vbYesNo = vbNo Then
Me.[Wave10%] = False
MsgBox "You will not be waiving the 10%", vbOKOnly
End If
End If
End Sub
--
Arvin Meyer, MCP, MVP
http://www.datastrat.com
http://www.mvps.org/access
http://www.accessmvp.com

DRMOB said:
I am having difficulty getting this right. When I put a check in Waive10%
I'd like to have a message appear asking "Are you sure you want to Waive
the
10%?", If you choose yes the check remains, if you choose No, the check
does
not remain. Also, if you uncheck Waive% you should get a message "You
will
NOT be waiving the 10%" If you choose OK the check does not remain, if
you
choose Cancel, the check will remain. The following only half works, it
does
not give me the Yes/No option or the OK/Cancel option. Any help is
greatly
appreciated.

Private Sub Waive10__BeforeUpdate(Cancel As Integer)
If Me![Waive10%] = True Then
Yes = True
No = False
MsgBox "You are waiving the 10%."
ElseIf Me![Waive10%] = False Then
OK = True
Cancel = False
MsgBox "You will not be waiving the 10%"

End If
End Sub
 
D

DRMOB

Great, this works. One thing I'd like to add is if the Waive10% is True and
then it gets changed to False, I'd like a message to say "Are you sure you
want to remove the Waive10%?"

Douglas J. Steele said:
Unfortunately, Arvin put a little too much air there. <g> (He's missing a
closing parenthesis in the first MsgBox statement)

Private Sub Waive10__AfterUpdate()
If Me![Waive10%] = True Then
If MsgBox("You are waiving the 10%.", vbYesNo) = vbNo Then
Me.[Wave10%] = False
MsgBox "You will not be waiving the 10%", vbOKOnly
End If
End If
End Sub


--
Doug Steele, Microsoft Access MVP

(no e-mails, please!)


Arvin Meyer said:
Try this (aircode):

Private Sub Waive10__AfterUpdate()
If Me![Waive10%] = True Then
If MsgBox("You are waiving the 10%.", vbYesNo = vbNo Then
Me.[Wave10%] = False
MsgBox "You will not be waiving the 10%", vbOKOnly
End If
End If
End Sub
--
Arvin Meyer, MCP, MVP
http://www.datastrat.com
http://www.mvps.org/access
http://www.accessmvp.com

DRMOB said:
I am having difficulty getting this right. When I put a check in Waive10%
I'd like to have a message appear asking "Are you sure you want to Waive
the
10%?", If you choose yes the check remains, if you choose No, the check
does
not remain. Also, if you uncheck Waive% you should get a message "You
will
NOT be waiving the 10%" If you choose OK the check does not remain, if
you
choose Cancel, the check will remain. The following only half works, it
does
not give me the Yes/No option or the OK/Cancel option. Any help is
greatly
appreciated.

Private Sub Waive10__BeforeUpdate(Cancel As Integer)
If Me![Waive10%] = True Then
Yes = True
No = False
MsgBox "You are waiving the 10%."
ElseIf Me![Waive10%] = False Then
OK = True
Cancel = False
MsgBox "You will not be waiving the 10%"

End If
End Sub
 
A

Arvin Meyer [MVP]

That's exacrly why I type "aircode". I'm writing code in a newsgroup posting
without any testing. Thanks for the catch, I can always rely on you to keep
me on the straight and narrow. You're better than an error handler. <g, d, &
r>
--
Arvin Meyer, MCP, MVP
http://www.datastrat.com
http://www.mvps.org/access
http://www.accessmvp.com

Douglas J. Steele said:
Unfortunately, Arvin put a little too much air there. <g> (He's missing a
closing parenthesis in the first MsgBox statement)

Private Sub Waive10__AfterUpdate()
If Me![Waive10%] = True Then
If MsgBox("You are waiving the 10%.", vbYesNo) = vbNo Then
Me.[Wave10%] = False
MsgBox "You will not be waiving the 10%", vbOKOnly
End If
End If
End Sub


--
Doug Steele, Microsoft Access MVP

(no e-mails, please!)


Arvin Meyer said:
Try this (aircode):

Private Sub Waive10__AfterUpdate()
If Me![Waive10%] = True Then
If MsgBox("You are waiving the 10%.", vbYesNo = vbNo Then
Me.[Wave10%] = False
MsgBox "You will not be waiving the 10%", vbOKOnly
End If
End If
End Sub
--
Arvin Meyer, MCP, MVP
http://www.datastrat.com
http://www.mvps.org/access
http://www.accessmvp.com

DRMOB said:
I am having difficulty getting this right. When I put a check in
Waive10%
I'd like to have a message appear asking "Are you sure you want to Waive
the
10%?", If you choose yes the check remains, if you choose No, the check
does
not remain. Also, if you uncheck Waive% you should get a message "You
will
NOT be waiving the 10%" If you choose OK the check does not remain, if
you
choose Cancel, the check will remain. The following only half works, it
does
not give me the Yes/No option or the OK/Cancel option. Any help is
greatly
appreciated.

Private Sub Waive10__BeforeUpdate(Cancel As Integer)
If Me![Waive10%] = True Then
Yes = True
No = False
MsgBox "You are waiving the 10%."
ElseIf Me![Waive10%] = False Then
OK = True
Cancel = False
MsgBox "You will not be waiving the 10%"

End If
End Sub
 
A

Arvin Meyer [MVP]

Do you want it to check on an already saved record? It doesn't make much
sense to test a new record being edited?
--
Arvin Meyer, MCP, MVP
http://www.datastrat.com
http://www.mvps.org/access
http://www.accessmvp.com

DRMOB said:
Great, this works. One thing I'd like to add is if the Waive10% is True
and
then it gets changed to False, I'd like a message to say "Are you sure you
want to remove the Waive10%?"

Douglas J. Steele said:
Unfortunately, Arvin put a little too much air there. <g> (He's missing a
closing parenthesis in the first MsgBox statement)

Private Sub Waive10__AfterUpdate()
If Me![Waive10%] = True Then
If MsgBox("You are waiving the 10%.", vbYesNo) = vbNo Then
Me.[Wave10%] = False
MsgBox "You will not be waiving the 10%", vbOKOnly
End If
End If
End Sub


--
Doug Steele, Microsoft Access MVP

(no e-mails, please!)


Arvin Meyer said:
Try this (aircode):

Private Sub Waive10__AfterUpdate()
If Me![Waive10%] = True Then
If MsgBox("You are waiving the 10%.", vbYesNo = vbNo Then
Me.[Wave10%] = False
MsgBox "You will not be waiving the 10%", vbOKOnly
End If
End If
End Sub
--
Arvin Meyer, MCP, MVP
http://www.datastrat.com
http://www.mvps.org/access
http://www.accessmvp.com

I am having difficulty getting this right. When I put a check in
Waive10%
I'd like to have a message appear asking "Are you sure you want to
Waive
the
10%?", If you choose yes the check remains, if you choose No, the
check
does
not remain. Also, if you uncheck Waive% you should get a message "You
will
NOT be waiving the 10%" If you choose OK the check does not remain, if
you
choose Cancel, the check will remain. The following only half works,
it
does
not give me the Yes/No option or the OK/Cancel option. Any help is
greatly
appreciated.

Private Sub Waive10__BeforeUpdate(Cancel As Integer)
If Me![Waive10%] = True Then
Yes = True
No = False
MsgBox "You are waiving the 10%."
ElseIf Me![Waive10%] = False Then
OK = True
Cancel = False
MsgBox "You will not be waiving the 10%"

End If
End Sub
 
D

DRMOB

Someone helped in figuring it out. Thanks

Private Sub Waive10__AfterUpdate()
If Me![Waive10%] = True Then
If MsgBox("Are you sure you want to waive the 10%", vbYesNo) = vbNo
Then
Me![Waive10%] = False
MsgBox "10% will NOT be waived", vbOKOnly
End If
Else
If MsgBox("Do you want to remove the 10% waiver?", vbYesNo) = vbYes
Then
Me![Waive10%] = False
MsgBox "You will not be waiving the 10%", vbOKOnly
Else
Me![Waive10%] = True
End If
End If
End Sub

Arvin Meyer said:
Do you want it to check on an already saved record? It doesn't make much
sense to test a new record being edited?
--
Arvin Meyer, MCP, MVP
http://www.datastrat.com
http://www.mvps.org/access
http://www.accessmvp.com

DRMOB said:
Great, this works. One thing I'd like to add is if the Waive10% is True
and
then it gets changed to False, I'd like a message to say "Are you sure you
want to remove the Waive10%?"

Douglas J. Steele said:
Unfortunately, Arvin put a little too much air there. <g> (He's missing a
closing parenthesis in the first MsgBox statement)

Private Sub Waive10__AfterUpdate()
If Me![Waive10%] = True Then
If MsgBox("You are waiving the 10%.", vbYesNo) = vbNo Then
Me.[Wave10%] = False
MsgBox "You will not be waiving the 10%", vbOKOnly
End If
End If
End Sub


--
Doug Steele, Microsoft Access MVP

(no e-mails, please!)


Try this (aircode):

Private Sub Waive10__AfterUpdate()
If Me![Waive10%] = True Then
If MsgBox("You are waiving the 10%.", vbYesNo = vbNo Then
Me.[Wave10%] = False
MsgBox "You will not be waiving the 10%", vbOKOnly
End If
End If
End Sub
--
Arvin Meyer, MCP, MVP
http://www.datastrat.com
http://www.mvps.org/access
http://www.accessmvp.com

I am having difficulty getting this right. When I put a check in
Waive10%
I'd like to have a message appear asking "Are you sure you want to
Waive
the
10%?", If you choose yes the check remains, if you choose No, the
check
does
not remain. Also, if you uncheck Waive% you should get a message "You
will
NOT be waiving the 10%" If you choose OK the check does not remain, if
you
choose Cancel, the check will remain. The following only half works,
it
does
not give me the Yes/No option or the OK/Cancel option. Any help is
greatly
appreciated.

Private Sub Waive10__BeforeUpdate(Cancel As Integer)
If Me![Waive10%] = True Then
Yes = True
No = False
MsgBox "You are waiving the 10%."
ElseIf Me![Waive10%] = False Then
OK = True
Cancel = False
MsgBox "You will not be waiving the 10%"

End If
End Sub
 
T

Tom Wickerath

Hi DRMOB,

You should not need these two lines of code:
Yes = True
No = False
The following only half works, it does
not give me the Yes/No option or the OK/Cancel option.

You are not using the optional buttons argument. Therefore, this value is
defaulting to 0, which equates to the constant vbOKOnly.

Syntax
MsgBox(prompt[, buttons] [, title] [, helpfile, context])

buttons Optional. Numeric expression that is the sum of values specifying
the number and type of buttons to display, the icon style to use, the
identity of the default button, and the modality of the message box. If
omitted, the default value for buttons is 0.

Use something like this:

Dim intResponse As Integer

intResponse = MsgBox ("You are waiving the 10%.", vbYesNo + vbInformation)
or
intResponse = MsgBox ("You are waiving the 10%.", vbOKCancel + vbInformation)

or, if you want to be more cryptic (not sure why anyone would want this):

intResponse = MsgBox ("You are waiving the 10%.", 68)
or
intResponse = MsgBox ("You are waiving the 10%.", 65)

and then test the value of intResponse accordingly. For example:

If intResponse = vbYes Then
'do this
Else
'do that
End If

Place your cursor within the Msgbox statement, and hit the F1 key to open
context-sensitive help for the Msgbox function. You also have an optional
title parameter available to you, to display in the blue title bar of the
message box.


Tom Wickerath
Microsoft Access MVP
https://mvp.support.microsoft.com/profile/Tom
http://www.access.qbuilt.com/html/expert_contributors.html
__________________________________________

DRMOB said:
I am having difficulty getting this right. When I put a check in Waive10%
I'd like to have a message appear asking "Are you sure you want to Waive the
10%?", If you choose yes the check remains, if you choose No, the check does
not remain. Also, if you uncheck Waive% you should get a message "You will
NOT be waiving the 10%" If you choose OK the check does not remain, if you
choose Cancel, the check will remain. The following only half works, it does
not give me the Yes/No option or the OK/Cancel option. Any help is greatly
appreciated.

Private Sub Waive10__BeforeUpdate(Cancel As Integer)
If Me![Waive10%] = True Then
Yes = True
No = False
MsgBox "You are waiving the 10%."
ElseIf Me![Waive10%] = False Then
OK = True
Cancel = False
MsgBox "You will not be waiving the 10%"

End If
End Sub
 

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