View Full Version : Solved: display msgbox once
av8tordude
01-30-2011, 04:16 PM
how can I get my message box to display only one time after it has already been display?
If LenB(Range("B11").Value) > 0 Then
If Year(frmPDCalc.Date1) <> Year(Range("B11").Value) Then
frmPDCalc.Ent1.Enabled = False
MsgBox "You may not register a FY" & Year(frmPDCalc.Date1) & " expense in a FY" & Year(Range("B11")) & " Expense Report Log.", vbExclamation, "PerDiem Traveler"
End If
End If
Dude
two possible ways
One in the sheet module
Option Explicit
Private m_MsgBoxCancelled As Boolean
Private Sub ValueStore()
m_MsgBoxCancelled = True
End Sub
Sub testp()
If LenB(Range("B11").Value) > 0 And Not m_MsgBoxCancelled Then
Call ValueStore
MsgBox "This works once"
End If
End Sub
or use a cell B11 to store a value
Sub testered()
If LenB(Range("B11").Value) > 0 And Range("B11").Value = 0 Then
Range("B11").Value = 1
MsgBox "This works once"
End If
End Sub
you can reset the B11 to 0 when you open the workbook
p45cal
01-30-2011, 07:15 PM
or use a static variable:Static AlreadyShown As Boolean
If LenB(Range("B11").Value) > 0 Then
If Year(frmPDCalc.Date1) <> Year(Range("B11").Value) Then
frmPDCalc.Ent1.Enabled = False
If Not AlreadyShown Then
MsgBox "You may not register a FY" & Year(frmPDCalc.Date1) & " expense in a FY" & Year(Range("B11")) & " Expense Report Log.", vbExclamation, "PerDiem Traveler"
AlreadyShown = True
End If
End If
End If
(untested). The message will show again (once) after the file is closed and re-opened.
av8tordude
01-30-2011, 07:31 PM
thank you both for you help! :friends:
P45cal, your code works seamlessly great. thank you.:beerchug:
Powered by vBulletin® Version 4.2.5 Copyright © 2024 vBulletin Solutions Inc. All rights reserved.