Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default SetFocus from ComboBox to Calendar gives Run-time error

I am using the dropdown event of a ComboBox to make the Calendar visible then
doing a SetFocus and I receive a Run-time error stating:
Automation error
The object invoked has disconnected from its clients.

I am fairly new to VBA and not really sure what is causing this and how to
work around it. I have tried just adding "on error resume next" but that
doesnt prevent the error. Can you give me an Idea what I am doing wrong?

The following is my code:
In a seperate Module
Sub ShowFormCalendar()
TrunkCalendarForm.Show
End Sub

In the Userform code itself:
Private Sub MondayComboBox_MouseDown(ByVal Button As Integer, ByVal Shift As
Integer, ByVal X As Single, ByVal Y As Single)
TrunkCalendar.Visible = True
TrunkCalendar.SetFocus 'After this is when i get the error
End Sub

Private Sub TrunkCalendar_Click()
MondayComboBox.Value = TrunkCalendar.Value
End Sub

Private Sub UserForm_Initialize()
TrunkCalendar.Value = Date
End Sub





  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1,298
Default SetFocus from ComboBox to Calendar gives Run-time error

Why are you using a combobox? The Date & Time picker control IS iffectively a
type of combobox.
Generally use a combo for a selection of dates or click a date picker tyo
pick a date. The code of the date picker can be used to add the selected date
to the combobox.

"Paulbram" wrote:

I am using the dropdown event of a ComboBox to make the Calendar visible then
doing a SetFocus and I receive a Run-time error stating:
Automation error
The object invoked has disconnected from its clients.

I am fairly new to VBA and not really sure what is causing this and how to
work around it. I have tried just adding "on error resume next" but that
doesnt prevent the error. Can you give me an Idea what I am doing wrong?

The following is my code:
In a seperate Module
Sub ShowFormCalendar()
TrunkCalendarForm.Show
End Sub

In the Userform code itself:
Private Sub MondayComboBox_MouseDown(ByVal Button As Integer, ByVal Shift As
Integer, ByVal X As Single, ByVal Y As Single)
TrunkCalendar.Visible = True
TrunkCalendar.SetFocus 'After this is when i get the error
End Sub

Private Sub TrunkCalendar_Click()
MondayComboBox.Value = TrunkCalendar.Value
End Sub

Private Sub UserForm_Initialize()
TrunkCalendar.Value = Date
End Sub





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
ComboBox processing error Jim Berglund Excel Programming 4 November 16th 04 02:08 AM
How Do I Get SetFocus On A ComboBox In A Frame? Minitman[_4_] Excel Programming 5 November 6th 04 05:23 AM
setfocus on multipage tab form gives error message Cheryl Excel Programming 3 July 28th 04 03:07 PM
error (ComboBox-?) Alex Excel Programming 2 June 18th 04 02:52 AM
Combobox run time error Oreg[_18_] Excel Programming 1 June 7th 04 04:46 AM


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

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"