PC Review


Reply
Thread Tools Rate Thread

ComboBox Queries

 
 
K
Guest
Posts: n/a
 
      18th Sep 2008
The code below list all the sheets name of active workbook in drop
down list. Because of the code line ".CLEAR" I am not able to get
combobox value. I want that when I select sheet name in drop down
list that name should appear as combobox text or value. and also how
can i stop some one to write in combobox as i want if some one write
in combobox the msgbox should appear saying "Select from drop down
list". Please can any friend solve my these queries about combobox.
Thanks

Private Sub ComboBox1_DropButtonClick()
Dim Sh As Worksheet
With ComboBox1
.CLEAR
For Each Sh In ActiveWorkbook.Sheets
If Sh.Name <> "" Then
.AddItem Sh.Name

End If

Next
End With

End Sub
 
Reply With Quote
 
 
 
 
Jim Rech
Guest
Posts: n/a
 
      18th Sep 2008
To block direct entry into the combo box just change its Style to
fmStyleDropDownList.

RE holding its value you might see how this works:

Dim ItemIndex As Integer

Private Sub ComboBox1_Change()
If ComboBox1.ListIndex >= 0 Then
ItemIndex = ComboBox1.ListIndex
End If
End Sub

Private Sub ComboBox1_DropButtonClick()
Dim Sh As Worksheet
With ComboBox1
.Clear
For Each Sh In ActiveWorkbook.Sheets
If Sh.Name <> "" Then
.AddItem Sh.Name
End If
Next
.ListIndex = ItemIndex
End With
End Sub


--
Jim
"K" <(E-Mail Removed)> wrote in message
news:09cb315b-8c60-40d5-88b3-(E-Mail Removed)...
| The code below list all the sheets name of active workbook in drop
| down list. Because of the code line ".CLEAR" I am not able to get
| combobox value. I want that when I select sheet name in drop down
| list that name should appear as combobox text or value. and also how
| can i stop some one to write in combobox as i want if some one write
| in combobox the msgbox should appear saying "Select from drop down
| list". Please can any friend solve my these queries about combobox.
| Thanks
|
| Private Sub ComboBox1_DropButtonClick()
| Dim Sh As Worksheet
| With ComboBox1
| .CLEAR
| For Each Sh In ActiveWorkbook.Sheets
| If Sh.Name <> "" Then
| .AddItem Sh.Name
|
| End If
|
| Next
| End With
|
| End Sub

 
Reply With Quote
 
K
Guest
Posts: n/a
 
      18th Sep 2008
On Sep 18, 1:03*pm, "Jim Rech" <jrr...@hotmail.com> wrote:
> To block direct entry into the combo box just change its Style to
> fmStyleDropDownList.
>
> RE holding its value you might see how this works:
>
> Dim ItemIndex As Integer
>
> Private Sub ComboBox1_Change()
> * * If ComboBox1.ListIndex >= 0 Then
> * * * * ItemIndex = ComboBox1.ListIndex
> * * End If
> End Sub
>
> Private Sub ComboBox1_DropButtonClick()
> * * Dim Sh As Worksheet
> * * With ComboBox1
> * * * * .Clear
> * * * * * For Each Sh In ActiveWorkbook.Sheets
> * * * * * * * If Sh.Name <> "" Then
> * * * * * * * * .AddItem Sh.Name
> * * * * * * * End If
> * * * * * Next
> * * * * * .ListIndex = ItemIndex
> * * End With
> End Sub
>
> --
> Jim"K" <kamranr1...@yahoo.co.uk> wrote in message
>
> news:09cb315b-8c60-40d5-88b3-(E-Mail Removed)...
> | The code below list all the sheets name of active workbook in drop
> | down list. *Because of the code line ".CLEAR" I am not able to get
> | combobox value. *I want that when I select sheet name in drop down
> | list that name should appear as combobox text or value. *and also how
> | can i stop some one to write in combobox as i want if some one write
> | in combobox the msgbox should appear saying "Select from drop down
> | list". *Please can any friend solve my these queries about combobox.
> | Thanks
> |
> | Private Sub ComboBox1_DropButtonClick()
> | Dim Sh As Worksheet
> | With ComboBox1
> | * *.CLEAR
> | * * *For Each Sh In ActiveWorkbook.Sheets
> | * * * * *If Sh.Name <> "" Then
> | * * * * * *.AddItem Sh.Name
> |
> | * * * * *End If
> |
> | * * *Next
> | End With
> |
> | End Sub


Thanks lot Jim
 
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
Upgrade a Combobox with queries list in access =?Utf-8?B?TWlrZSBIZXJuYW5kZXo=?= Microsoft Access Form Coding 1 17th Nov 2005 07:27 AM
RE: Combobox, subforms and queries =?Utf-8?B?U3ByaW5rcw==?= Microsoft Access Forms 0 30th Aug 2005 01:54 PM
Re: How to list all queries only of a database in a combobox. Allen Browne Microsoft Access Forms 4 13th Jul 2005 03:24 AM
How to list all queries only of a database in a combobox. xpengi Microsoft Access Forms 0 11th Jul 2005 03:22 PM
To choose queries in Combobox an Microsoft Access Forms 2 11th Oct 2004 12:56 PM


Features
 

Advertising
 

Newsgroups
 


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