473,395 Members | 1,783 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,395 software developers and data experts.

visual basic combo boxes??

Does anyone know how to:
Populate a ComboBox with all the days of the year for 2005
with out doing it manually

Nov 13 '05 #1
3 1468
boss0021 wrote:
Does anyone know how to:
Populate a ComboBox with all the days of the year for 2005
with out doing it manually


There are numerous times where having a utility table full of numbers is
handy and this can be one of them. If you have a single field table
populated with the numbers from say... negative 5000 to positive 5000 then
you can use it for all sorts of date stuff. In your case you could use a
RowSource for your ComboBox of..

SELECT DateAdd("d", [NumberFieldName], DateSerial(Year(Date()), 1,1)) As
DateFieldName
FROM UtilityNumbers
WHERE [NumberFieldName] Between 0 and 364

Of course how many numbers you want to populate the utility table with is up
to you. I picked +/- 5000 just because it's a nice round figure, but you
could start with just 365 numbers and add to it as different needs arise.
You can see how using different intervals in the DateAdd could give you a
list of dates that are months apart, weeks apart, or whatever.

--
I don't check the Email account attached
to this message. Send instead to...
RBrandt at Hunter dot com
Nov 13 '05 #2
boss0021 wrote:
Does anyone know how to:
Populate a ComboBox with all the days of the year for 2005
with out doing it manually


You need to write a function for it. Look for the help topic
"RowSourceType Property (User-Defined Function) — Code Argument Values"

Copy the function below into the code module for the form containing the
combo box. This is for 2005 only. Modify it to do different years.

In the combo's RowSource enter
ListDays
(normally where you see ValueList or Table/Query under Data tab.

Function ListDays(fld As Control, id As Variant, row As Variant, col As
Variant, code As Variant) As Variant
Static strRows() As String
Static Entries As Integer

Dim ReturnVal As Variant
Dim datStart As Date
Dim datEnd As Date
Dim datFor As Date

ReturnVal = Null
Select Case code
Case acLBInitialize ' Initialize.
datStart = DateSerial(Year(Date), 1, 1)
datEnd = DateSerial(Year(Date), 12, 31)
For datFor = datStart To datEnd
ReDim Preserve strRows(Entries)
strRows(Entries) = datFor
Entries = Entries + 1
Next
ReturnVal = True
Case acLBOpen ' Open.
ReturnVal = Timer ' Generate unique ID for control.
Case acLBGetRowCount ' Get number of rows.
ReturnVal = Entries
Case acLBGetColumnCount ' Get number of columns.
ReturnVal = 1
Case acLBGetColumnWidth ' Column width.
ReturnVal = -1 ' -1 forces use of default width.
Case acLBGetValue ' Get data.
ReturnVal = strRows(row)
Case acLBEnd ' End.
Erase strRows
End Select
ListDays = ReturnVal
End Function
Nov 13 '05 #3
Go to the toolbox and use the Calendar control instead.

--
PC Datasheet
Your Resource For Help With Access, Excel And Word Applications
re******@pcdatasheet.com
www.pcdatasheet.com
"boss0021" <zj********@aol.com> wrote in message
news:11**********************@g14g2000cwa.googlegr oups.com...
Does anyone know how to:
Populate a ComboBox with all the days of the year for 2005
with out doing it manually

Nov 13 '05 #4

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

0
by: Krisa | last post by:
Hello all, I just discovered something (stop me if you've heard this before....) that was causing me a significant performance hit when opening a form with subforms. To speed up loading the...
2
by: dt | last post by:
hello, I'm still new to win32 programming and I have a small problem. I am making a simple application. The main GUI is a dialog box with check boxes, radio buttons, combo boxes etc. The...
0
by: Tom | last post by:
I have some very strange issues with combo boxes on a tab control. Here's the scenario: I have a Windows Forms form that has a tab control on it, with two (2) tabs. Tab 2 happens to have a number...
3
by: robertoathome | last post by:
Hello, I successully adapted a search form from a microsoft example into my own db. MS Example I type search parameters in 2 boxes and the results are returned in a new, basic query window. ...
4
by: Dave | last post by:
I wasn't sure how to search for previous posts about this, it felt real specific. Ok so here's the database & problem: I have 4 combo boxes: cboServer, cboPolicy, cboDB, and cboApplication. ...
6
by: Dave | last post by:
I want to put the information that the user selects in my combo boxes into a subform that lies on the same form as the combo boxes. Thanks for your help already, Dave
1
by: Dave | last post by:
Hello all, First I'd like to apologize...This post was meant to be put in my previous post, but I tried many times without success to reply within my previous post. Now here goes... I have a...
2
by: Dave | last post by:
I have 3 tables of information feeding into 4 combo boxes on my main form (DR Form). I have as many list boxes (acting as text boxes) as there are fields in each one of the 3 tables. Once...
8
by: stuart wieder | last post by:
i have an application containing a header with 5 filters (combo boxes) and 2 search boxes (text boxes). When the search boxes are used and return no records in the detail of the form, the actual...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.