473,666 Members | 2,461 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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 1480
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
"RowSourceT ype 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 acLBGetColumnCo unt ' Get number of columns.
ReturnVal = 1
Case acLBGetColumnWi dth ' 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******@pcdata sheet.com
www.pcdatasheet.com
"boss0021" <zj********@aol .com> wrote in message
news:11******** **************@ g14g2000cwa.goo glegroups.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
3522
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 form, I set the rowsources of its, and its subforms', combo boxes in the "Enter" events of the combo boxes. That's the standard trick for not loading the rowsource unless/until the user actually needs the combo box. For example:
2
4431
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 problem I'm having is that I have two combo boxes (both dropdown). One of them works fine; when you click the arrow on the right side of the box, the list drops down. With the other combo box, when you click the arrow, it looks like something tries...
0
1597
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 of text and combo boxes on it (in panels on the tab). These combos were originally simple drop down lists - i.e. you had to select from the list and couldn't enter anything of your own. At that time everything worked fine. Now, the users...
3
1825
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. I created: 2 text boxes 1 Command button ( search ) 1 Macro to open the query
4
2359
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. The idea behind the database is for a user to search/ select desired information in any kind of combination between the 4 combo boxes. Then the user clicks a button (btnSearch) and subsequently a query ("Search Function") is run that shows all 4...
6
3674
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
2905
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 main form (RD Form) with 4 combo boxes (i.e. cbo1, cbo2, etc) and a subdatasheet (the subform...let's call it subInfo) below the combo boxes on the RD Form. I hope this eliminates any confusion of the
2
3267
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 selecting from the combo box, I have all the combo boxes, using afterupdate, populating their respective list boxes. These text boxes are directly correlated to the combo box selection using SQL. Here is an example from the afterupdate event in the...
8
1348
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 search word in the header becomes invisible, though the text box is still populated with the search data. How do i prevent the search data from becoming invisible?
0
8454
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
8878
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
8785
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
8560
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 Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
7389
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
6200
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
5671
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
2
2012
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
2
1778
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.