Hi,
I have a Combobox in a form (cmbDate) that looks up a list of dates from a sheet formatted (dd/mm.yy)
When I select a date it displays correctly but when I select a date from the list it then converts it to a number and saves it in that format.
Ive tried to format the combobox using the following code:
Me.cmbDate.value= Format (me.cmbDate.value, "dd/mm/yy")
Neither works. In first case I get error "Wrong number of arguments or invalid property assignment" with the word "Format" highlighted. In second case I get error "Method or data member not found": with the second ".Date" highlighted.Me.cmbDate.value= Format (me.cmbDate.value, "dd/mm/yy") I've also tried Me.cmbDate.date= Format (me.cmbDate.date, "dd/mm/yy")
All I need to do is to be able to format the combobox field so that when it reads or writes a value it will be in the correct format.
I suspect I'm going to have the same issue with my amounts (number) fields
Regards,
Alan
Good morning AlanAnderson
What do you mean by "saves it in that format"? What are you doing with the date you select?
One fo the problems with using VBA is that you lose certain formats, such as dates, the standard Microsoft preferred format is applied. Everytime you use your selection after that, you will need to re-specify its format. The format you apply to display it in the combobox will only make it look how you want - the underlying date data will be unchanged.
HTH
DominicB
Hi,
Thanks for the response. I am looking up dates from a table (dd/mm/yy) The form is supposed to allow user to select one of the dates from the table. When user clicks on a date it is displayed on the form as a number eg 01/01/10 is displayed as 40179. I need it to display as dd/mm/yy and then, if edited, to be saved in the list as a date, not a number.
Regards,
Alan
Hi AlanAnderson
When you say "form" are you referring to a UserForm?
If so, how are you showing the date on the UserFrom - are you using a TextBox?
DominicB
Is your combobox bound to the worksheet using rowsource and/or controlsource?
Hi Dominic,
No its a standard combobox called from the toolkit.
Regards
Alan
Hi Romperstomper,
I used a line in my code stating:
me.cmbDate.rowsource="A2:A" & FinalRow
I hope that answers the question.
Regards,
Alan
BTW "Romperstomper" sounds awfully like rugrat stamper - hope not![]()
First thing: don't bind controls to sheets. I suggest you use:
instead.me.cmbDate.List = Range("A2:A" & FinalRow).Value
Second thing: no, romperstomper is a film.![]()
Hi All,
Still have problem.
I have tried use of DTPicker which seems to do what I need. I just have concern about distributing programme to other machines. Will this be a problem?
Regards,
Alan
DatePicker will be a problem if the end user does not have the control on their machine, & Excel 2010 does not support them. See alternatives in the addins section here
Hope that helps.
RoyUK
--------
If you are pleased with a member's answer then use the Star icon to rate it, if you are pleased enough to part with cash consider a donation to Children in Need
For Excel Tips & Solutions, free examples and tutorials why not check out my downloads
New members please read & follow the Forum Rules
Remember to mark your questions Solved and rate the answer(s)
Does the combo in the attached work for you?
There are currently 1 users browsing this thread. (0 members and 1 guests)
Bookmarks