Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 37
Default MsgBox Displays Twice

I have 2 combo boxes for Dates; ComboBx1 = StartDAte, Combo2=EndDate. I
have in Combo box VB Code If EndDate<StartDate, then MsgBx dislays DAte Input
Error. Then, when I add a code to set the EndDateCombo.Value=Default Value,
the MsgBox Displays AGAIN. Does anyone know how to not have it reappear????
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1,298
Default MsgBox Displays Twice

are these on a form? can you show us the code please?

"DogLover" wrote:

I have 2 combo boxes for Dates; ComboBx1 = StartDAte, Combo2=EndDate. I
have in Combo box VB Code If EndDate<StartDate, then MsgBx dislays DAte Input
Error. Then, when I add a code to set the EndDateCombo.Value=Default Value,
the MsgBox Displays AGAIN. Does anyone know how to not have it reappear????

  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 37
Default MsgBox Displays Twice

This is on the View Code attached to the EndDate Combo Box.

Private Sub ComboBoxEndDate_Change()
If ComboBoxEndDate.Value < ComboBoxStartDate.Value Then
MsgBox ComboBoxEndDate.Value + " MUST be GREATER than Start
Date!", vbOKOnly + vbWarning, "Date Input Error"
Worksheets("RFJ").Range("N1") = 1
ComboBoxEndDate.Text =
Format(CDate(Worksheets("Demo").Range("A22")), "mm/yyyy") ' Reset to Default
Orient End Date

Else
ComboBoxEndDate.Text = Format(CDate(ComboBoxEndDate.Value),
"mm/yyyy")
End If
End Sub




"Patrick Molloy" wrote:

are these on a form? can you show us the code please?

"DogLover" wrote:

I have 2 combo boxes for Dates; ComboBx1 = StartDAte, Combo2=EndDate. I
have in Combo box VB Code If EndDate<StartDate, then MsgBx dislays DAte Input
Error. Then, when I add a code to set the EndDateCombo.Value=Default Value,
the MsgBox Displays AGAIN. Does anyone know how to not have it reappear????

  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1,298
Default MsgBox Displays Twice

the change event itself chnages the value, so that raises the event
again....add the two lines indicated

Private Sub ComboBoxEndDate_Change()
If ComboBoxEndDate.Value < ComboBoxStartDate.Value Then
MsgBox ComboBoxEndDate.Value + " MUST be GREATER than Start
Date!", vbOKOnly + vbWarning, "Date Input Error"
Worksheets("RFJ").Range("N1") = 1

Application.EnableEvents = FALSE

ComboBoxEndDate.Text =
Format(CDate(Worksheets("Demo").Range("A22")), "mm/yyyy") ' Reset to Default
Orient End Date

Else
ComboBoxEndDate.Text = Format(CDate(ComboBoxEndDate.Value),
"mm/yyyy")
End If
Application.EnableEvents = TRUE
End Sub




"DogLover" wrote:

This is on the View Code attached to the EndDate Combo Box.

Private Sub ComboBoxEndDate_Change()
If ComboBoxEndDate.Value < ComboBoxStartDate.Value Then
MsgBox ComboBoxEndDate.Value + " MUST be GREATER than Start
Date!", vbOKOnly + vbWarning, "Date Input Error"
Worksheets("RFJ").Range("N1") = 1
ComboBoxEndDate.Text =
Format(CDate(Worksheets("Demo").Range("A22")), "mm/yyyy") ' Reset to Default
Orient End Date

Else
ComboBoxEndDate.Text = Format(CDate(ComboBoxEndDate.Value),
"mm/yyyy")
End If
End Sub




"Patrick Molloy" wrote:

are these on a form? can you show us the code please?

"DogLover" wrote:

I have 2 combo boxes for Dates; ComboBx1 = StartDAte, Combo2=EndDate. I
have in Combo box VB Code If EndDate<StartDate, then MsgBx dislays DAte Input
Error. Then, when I add a code to set the EndDateCombo.Value=Default Value,
the MsgBox Displays AGAIN. Does anyone know how to not have it reappear????

  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 37
Default MsgBox Displays Twice

Still popping up twice. I wonder if there is another event to use rather
than the change?

"Patrick Molloy" wrote:

the change event itself chnages the value, so that raises the event
again....add the two lines indicated

Private Sub ComboBoxEndDate_Change()
If ComboBoxEndDate.Value < ComboBoxStartDate.Value Then
MsgBox ComboBoxEndDate.Value + " MUST be GREATER than Start
Date!", vbOKOnly + vbWarning, "Date Input Error"
Worksheets("RFJ").Range("N1") = 1

Application.EnableEvents = FALSE

ComboBoxEndDate.Text =
Format(CDate(Worksheets("Demo").Range("A22")), "mm/yyyy") ' Reset to Default
Orient End Date

Else
ComboBoxEndDate.Text = Format(CDate(ComboBoxEndDate.Value),
"mm/yyyy")
End If
Application.EnableEvents = TRUE
End Sub




"DogLover" wrote:

This is on the View Code attached to the EndDate Combo Box.

Private Sub ComboBoxEndDate_Change()
If ComboBoxEndDate.Value < ComboBoxStartDate.Value Then
MsgBox ComboBoxEndDate.Value + " MUST be GREATER than Start
Date!", vbOKOnly + vbWarning, "Date Input Error"
Worksheets("RFJ").Range("N1") = 1
ComboBoxEndDate.Text =
Format(CDate(Worksheets("Demo").Range("A22")), "mm/yyyy") ' Reset to Default
Orient End Date

Else
ComboBoxEndDate.Text = Format(CDate(ComboBoxEndDate.Value),
"mm/yyyy")
End If
End Sub




"Patrick Molloy" wrote:

are these on a form? can you show us the code please?

"DogLover" wrote:

I have 2 combo boxes for Dates; ComboBx1 = StartDAte, Combo2=EndDate. I
have in Combo box VB Code If EndDate<StartDate, then MsgBx dislays DAte Input
Error. Then, when I add a code to set the EndDateCombo.Value=Default Value,
the MsgBox Displays AGAIN. Does anyone know how to not have it reappear????



  #6   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 35,218
Default MsgBox Displays Twice

application.enableevents won't help with these controls.

But you can keep track of it yourself.

At the top of the userform (it's a userform, right?) module:

Dim BlkProc as boolean
.....

Private Sub ComboBoxEndDate_Change()

if blkproc = true then
exit sub
end if

If ComboBoxEndDate.Value < ComboBoxStartDate.Value Then
'use & to concatenate text and + to add numbers
MsgBox ComboBoxEndDate.Value & _
" MUST be GREATER than Start Date!", &
vbOKOnly + vbWarning, "Date Input Error"
Worksheets("RFJ").Range("N1") = 1
blkproc = true
ComboBoxEndDate.Text = Format(CDate(Worksheets("Demo").Range("A22")), _
"mm/yyyy") ' Reset to Default Orient End Date
blkproc = false
Else
blkproc = true
ComboBoxEndDate.Text = Format(CDate(ComboBoxEndDate.Value), "mm/yyyy")
blkproc = false
End If
End Sub

==============
An alternative that I'd use if I were you would be to add a label (make it a red
font) and instead of displaying a msgbox, you could change the .caption of the
label.

I think it's a little "cleaner" for the user, too:

Private Sub ComboBoxEndDate_Change()

if blkproc = true then
exit sub
end if

me.label1.caption = "" 'if it's ok, make it invisible

If ComboBoxEndDate.Value < ComboBoxStartDate.Value Then
'use & to concatenate text and + to add numbers
me.label1.caption = ComboBoxEndDate.Value & _
" MUST be GREATER than Start Date!"
Worksheets("RFJ").Range("N1") = 1
blkproc = true
ComboBoxEndDate.Text = Format(CDate(Worksheets("Demo").Range("A22")), _
"mm/yyyy") ' Reset to Default Orient End Date
blkproc = false
Else
blkproc = true
ComboBoxEndDate.Text = Format(CDate(ComboBoxEndDate.Value), "mm/yyyy")
blkproc = false
End If
End Sub

(You'll still want to stop the extra processing, though.)

DogLover wrote:

This is on the View Code attached to the EndDate Combo Box.

Private Sub ComboBoxEndDate_Change()
If ComboBoxEndDate.Value < ComboBoxStartDate.Value Then
MsgBox ComboBoxEndDate.Value + " MUST be GREATER than Start
Date!", vbOKOnly + vbWarning, "Date Input Error"
Worksheets("RFJ").Range("N1") = 1
ComboBoxEndDate.Text =
Format(CDate(Worksheets("Demo").Range("A22")), "mm/yyyy") ' Reset to Default
Orient End Date

Else
ComboBoxEndDate.Text = Format(CDate(ComboBoxEndDate.Value),
"mm/yyyy")
End If
End Sub

"Patrick Molloy" wrote:

are these on a form? can you show us the code please?

"DogLover" wrote:

I have 2 combo boxes for Dates; ComboBx1 = StartDAte, Combo2=EndDate. I
have in Combo box VB Code If EndDate<StartDate, then MsgBx dislays DAte Input
Error. Then, when I add a code to set the EndDateCombo.Value=Default Value,
the MsgBox Displays AGAIN. Does anyone know how to not have it reappear????


--

Dave Peterson
Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
inserted comment not displays in the cell it displays on top row S.Kumar Excel Worksheet Functions 1 September 22nd 09 07:32 PM
displays Karen Excel Discussion (Misc queries) 2 April 19th 09 12:47 PM
Workbooks.Open suppresses MsgBox Displays when Macro is run MichaelDavid Excel Programming 4 October 3rd 08 12:38 AM
Help with togglebutton that displays jpg caj Excel Discussion (Misc queries) 2 March 7th 07 02:44 PM
Formula window displays correct answer while cell displays incorre MMV Excel Worksheet Functions 3 November 10th 04 09:28 PM


All times are GMT +1. The time now is 11:33 PM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"