PC Review


Reply
Thread Tools Rate Thread

ComboBox doing a double take?

 
 
Brettjg
Guest
Posts: n/a
 
      15th Apr 2009
I have a ComboBox with a click routine attached to it to perform various
tasks. If I click 'cancel' on the confirm box (from the CALLED macro) then it
comes up again. It doesn't matter whether events are on/off. That's a bit odd
isn't it?


Private Sub ComboBox1_Change()
Application.EnableEvents = False
If ComboBox1.Text = "ACTION LIST" Then: GoTo EXIT_SUB

If ComboBox1.Text = "CREATE NEW CLIENT" Then
ComboBox1.Text = "ACTION LIST"
Range("title.1").Select
Application.Run "PERSONAL.xls!CREATE_NEW_CLIENT", "CREATE NEW CLIENT"
GoTo EXIT_SUB
end if

EXIT_SUB:
Application.EnableEvents = True
End Sub

The routine that is called is:

Sub CREATE_NEW_CLIENT(act)
answer = MsgBox(act, vbOKCancel + vbDefaultButton2, "CONFIRM THE ACTION")
If answer = 2 Then: Exit Sub
Dim fso As Object, SourceFile, DestinationFile
Set fso = CreateObject("scripting.FileSystemObject")
fso.createFolder "C:\1. ACTIVE CLIENTS\" & Range("foldername")
ActiveWorkbook.SaveAs Filename:=Range("Path.IF").Value, CreateBackup:=False
End Sub
 
Reply With Quote
 
 
 
 
Patrick Molloy
Guest
Posts: n/a
 
      15th Apr 2009
I wasn't able to replicate the issue. Here is my test code...and it works as
expected...note the use of "select case", this will more easily allow you to
add further commands to the combobox and initiate other code later...

Option Explicit

Private Sub ComboBox1_Change()
If ComboBox1.Text = "ACTION LIST" Then Exit Sub

Application.EnableEvents = False
Select Case ComboBox1.Text
Case "CREATE NEW CLIENT"
ComboBox1.Text = "ACTION LIST"
'Range("title.1").Select
CREATE_NEW_CLIENT "CREATE NEW CLIENT"
Case Else
End Select
Application.EnableEvents = True
End Sub


Sub CREATE_NEW_CLIENT(act)
Dim answer As Long
If MsgBox(act, vbOKCancel + vbDefaultButton2, "CONFIRM THE ACTION") =
vbOK Then

Dim fso As Object, SourceFile, DestinationFile
'Set fso = CreateObject("scripting.FileSystemObject")
'fso.createFolder "C:\1. ACTIVE CLIENTS\" & Range("foldername")
'ActiveWorkbook.SaveAs Filename:=Range("Path.IF").Value,
CreateBackup:=False
MsgBox "Saved"
End If
End Sub

"Brettjg" wrote:

> I have a ComboBox with a click routine attached to it to perform various
> tasks. If I click 'cancel' on the confirm box (from the CALLED macro) then it
> comes up again. It doesn't matter whether events are on/off. That's a bit odd
> isn't it?
>
>
> Private Sub ComboBox1_Change()
> Application.EnableEvents = False
> If ComboBox1.Text = "ACTION LIST" Then: GoTo EXIT_SUB
>
> If ComboBox1.Text = "CREATE NEW CLIENT" Then
> ComboBox1.Text = "ACTION LIST"
> Range("title.1").Select
> Application.Run "PERSONAL.xls!CREATE_NEW_CLIENT", "CREATE NEW CLIENT"
> GoTo EXIT_SUB
> end if
>
> EXIT_SUB:
> Application.EnableEvents = True
> End Sub
>
> The routine that is called is:
>
> Sub CREATE_NEW_CLIENT(act)
> answer = MsgBox(act, vbOKCancel + vbDefaultButton2, "CONFIRM THE ACTION")
> If answer = 2 Then: Exit Sub
> Dim fso As Object, SourceFile, DestinationFile
> Set fso = CreateObject("scripting.FileSystemObject")
> fso.createFolder "C:\1. ACTIVE CLIENTS\" & Range("foldername")
> ActiveWorkbook.SaveAs Filename:=Range("Path.IF").Value, CreateBackup:=False
> End Sub

 
Reply With Quote
 
Brettjg
Guest
Posts: n/a
 
      15th Apr 2009
Hi Patrick

Man that was a tricky one. It was all to do with getting "ACTION LIST" back
into the comboBox text. Your suggestion of select case was very appropriate,
as there are several cases to test. Thanks very much for your help. Brett

"Patrick Molloy" wrote:

> I wasn't able to replicate the issue. Here is my test code...and it works as
> expected...note the use of "select case", this will more easily allow you to
> add further commands to the combobox and initiate other code later...
>
> Option Explicit
>
> Private Sub ComboBox1_Change()
> If ComboBox1.Text = "ACTION LIST" Then Exit Sub
>
> Application.EnableEvents = False
> Select Case ComboBox1.Text
> Case "CREATE NEW CLIENT"
> ComboBox1.Text = "ACTION LIST"
> 'Range("title.1").Select
> CREATE_NEW_CLIENT "CREATE NEW CLIENT"
> Case Else
> End Select
> Application.EnableEvents = True
> End Sub
>
>
> Sub CREATE_NEW_CLIENT(act)
> Dim answer As Long
> If MsgBox(act, vbOKCancel + vbDefaultButton2, "CONFIRM THE ACTION") =
> vbOK Then
>
> Dim fso As Object, SourceFile, DestinationFile
> 'Set fso = CreateObject("scripting.FileSystemObject")
> 'fso.createFolder "C:\1. ACTIVE CLIENTS\" & Range("foldername")
> 'ActiveWorkbook.SaveAs Filename:=Range("Path.IF").Value,
> CreateBackup:=False
> MsgBox "Saved"
> End If
> End Sub
>
> "Brettjg" wrote:
>
> > I have a ComboBox with a click routine attached to it to perform various
> > tasks. If I click 'cancel' on the confirm box (from the CALLED macro) then it
> > comes up again. It doesn't matter whether events are on/off. That's a bit odd
> > isn't it?
> >
> >
> > Private Sub ComboBox1_Change()
> > Application.EnableEvents = False
> > If ComboBox1.Text = "ACTION LIST" Then: GoTo EXIT_SUB
> >
> > If ComboBox1.Text = "CREATE NEW CLIENT" Then
> > ComboBox1.Text = "ACTION LIST"
> > Range("title.1").Select
> > Application.Run "PERSONAL.xls!CREATE_NEW_CLIENT", "CREATE NEW CLIENT"
> > GoTo EXIT_SUB
> > end if
> >
> > EXIT_SUB:
> > Application.EnableEvents = True
> > End Sub
> >
> > The routine that is called is:
> >
> > Sub CREATE_NEW_CLIENT(act)
> > answer = MsgBox(act, vbOKCancel + vbDefaultButton2, "CONFIRM THE ACTION")
> > If answer = 2 Then: Exit Sub
> > Dim fso As Object, SourceFile, DestinationFile
> > Set fso = CreateObject("scripting.FileSystemObject")
> > fso.createFolder "C:\1. ACTIVE CLIENTS\" & Range("foldername")
> > ActiveWorkbook.SaveAs Filename:=Range("Path.IF").Value, CreateBackup:=False
> > End Sub

 
Reply With Quote
 
 
 
Reply

Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

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


Similar Threads
Thread Thread Starter Forum Replies Last Post
double dropdown/combobox arie Microsoft Excel Discussion 6 9th Nov 2005 02:43 PM
Re: ComboBox double click? perspolis Microsoft C# .NET 0 11th Jan 2005 09:02 AM
ComboBox double click perspolis Microsoft C# .NET 4 2nd Jan 2005 11:12 AM
double click on combobox Wajih-ur-Rehman Microsoft C# .NET 3 30th Apr 2004 07:28 PM
ComboBox Double Click MadCrazyNewbie Microsoft VB .NET 1 17th Apr 2004 04:38 PM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 01:43 AM.