ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Setting Combo Box to display a blank (https://www.excelbanter.com/excel-programming/383729-setting-combo-box-display-blank.html)

sot

Setting Combo Box to display a blank
 
I have a combo box on a user form. I have set the Row source as =list!a1:a5.
However when I display the form the value displayed in the combo box is the
one from the previous record.

How do I get it to clear and show a blank each time?



joel

Setting Combo Box to display a blank
 
Comboboxes remember their last settings. You have to initialize tthe box
before the .SHOW to change the settings.

"sot" wrote:

I have a combo box on a user form. I have set the Row source as =list!a1:a5.
However when I display the form the value displayed in the combo box is the
one from the previous record.

How do I get it to clear and show a blank each time?



sot

Setting Combo Box to display a blank
 
Thanks. Could you help me with that please. I don't have the knowledge.
This is what I have so far:

Sub Button1_Click()

Range("B3").Value = Worksheets("table").Range("A20000").End(xlUp).Row
Range("C1").Value = ""
Range("D1").Value = 0
Range("E1").Value = Format(Date, "dd/MM/yy")

myform.Show
myform.fname.SetFocus


End Sub

"Joel" wrote:

Comboboxes remember their last settings. You have to initialize tthe box
before the .SHOW to change the settings.

"sot" wrote:

I have a combo box on a user form. I have set the Row source as =list!a1:a5.
However when I display the form the value displayed in the combo box is the
one from the previous record.

How do I get it to clear and show a blank each time?



Bob Phillips

Setting Combo Box to display a blank
 
myform.ComboBox1.ListIndex = -1
myform.Show


--
---
HTH

Bob

(there's no email, no snail mail, but somewhere should be gmail in my addy)



"sot" wrote in message
...
Thanks. Could you help me with that please. I don't have the knowledge.
This is what I have so far:

Sub Button1_Click()

Range("B3").Value = Worksheets("table").Range("A20000").End(xlUp).Row
Range("C1").Value = ""
Range("D1").Value = 0
Range("E1").Value = Format(Date, "dd/MM/yy")

myform.Show
myform.fname.SetFocus


End Sub

"Joel" wrote:

Comboboxes remember their last settings. You have to initialize tthe box
before the .SHOW to change the settings.

"sot" wrote:

I have a combo box on a user form. I have set the Row source as
=list!a1:a5.
However when I display the form the value displayed in the combo box
is the
one from the previous record.

How do I get it to clear and show a blank each time?





Tom Ogilvy

Setting Combo Box to display a blank
 
If you want to be able to select the same selection as previously selected then

Private Sub ListBox1_MouseDown(ByVal Button As _
Integer, ByVal Shift As Integer, ByVal X As Single, _
ByVal Y As Single)
Listbox1.Listindex = -1
End Sub

this won't visibly clear the selection if you are issuing a show command
after a hide. for that, you would need to issue the same command in the
useform_activate event I would suspect. or better yet, issue it just before
the show command

myform.ListBox1.ListIndex = -1
myform.Show

--
Regards,
Tom Ogilvy

"sot" wrote:

Thanks. Could you help me with that please. I don't have the knowledge.
This is what I have so far:

Sub Button1_Click()

Range("B3").Value = Worksheets("table").Range("A20000").End(xlUp).Row
Range("C1").Value = ""
Range("D1").Value = 0
Range("E1").Value = Format(Date, "dd/MM/yy")

myform.Show
myform.fname.SetFocus


End Sub

"Joel" wrote:

Comboboxes remember their last settings. You have to initialize tthe box
before the .SHOW to change the settings.

"sot" wrote:

I have a combo box on a user form. I have set the Row source as =list!a1:a5.
However when I display the form the value displayed in the combo box is the
one from the previous record.

How do I get it to clear and show a blank each time?




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

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
ExcelBanter.com