If and Msgbox

  • Thread starter Thread starter Cadburys
  • Start date Start date
C

Cadburys

Hi

I know that this might be fairly simple but I just cant seem to get it
right.

If Me.LegalClient = True Then
MsgBox "Has the client specified the deadline time?", vbYesNo, "Deadline"

If vbYes Then
Me.fldDeadlineSpecified = True
Me.fldDeadlineDate.BackColor = 255
Me.fldDeadlineTime.BackColor = 255
ElseIf vbNo Then
Call DeadlineCheck

If Me.LegalClient = False Then
Call DeadlineCheck
End If

Can this be done?

Thank you, Cadburys.
 
you need to put your if around the message box to get the respose

If Me.LegalClient = True Then
If MsgBox("Has the client ...?", vbYesNo, "Deadline") = vbYes Then
Me.fldDeadlineSpecified = True
Me.fldDeadlineDate.BackColor = 255
Me.fldDeadlineTime.BackColor = 255
Else
Call DeadlineCheck
End If
Else
Call DeadlineCheck
End If
 
If you look at the VBA help on the subject, MsgBox Function, more
specifically at the example provided, you'll see the proper approach! Try
something more like:

If Me.LegalClient = True Then
Response = MsgBox("Has the client specified the deadline time?",
vbYesNo, "Deadline")

If Response = vbYes Then
Me.fldDeadlineSpecified = True
Me.fldDeadlineDate.BackColor = 255
Me.fldDeadlineTime.BackColor = 255
Else
Call DeadlineCheck
End If
Else
Call DeadlineCheck
End If

Your code seemed incomplete so I did some minor cleanup. Also, make sure
you indent your code properly, it will facilitate your life tremendously and
don't forget to Dim the variables in your code (ie: Response) and add error
handling to your procedure.
--
Hope this helps,

Daniel Pineault
http://www.cardaconsultants.com/
For Access Tips and Examples: http://www.devhut.net
Please rate this post using the vote buttons if it was helpful.
 
Back
Top