sequence of dates or times on a combo box

S

SAm

hi,

how do i get a list of dates or all hours of the day and night in combo box
on a form. specifically, i would like my combo box to have all the hours of
the day listed as 1:00am. do i need to type them all out as a list, or is
there some automated way.

btw, i am hoping to have less questions, or atleast have better questions as
soon as my set of books arrive. just ordered the access developement set from
cybex.

thanks,

sam
 
W

Wayne Morgan

If all you want is the 24 entries (one for each hour), it might be easiet to
just use a list as the Row Source and type them in to the Row Source
yourself. If you want something that you can dynamically change and have the
changes remain after closing the form, then you'll need to store the entries
in a table and use a table or query as the Row Source. The advatage of the
query over the table is being able to sort the entries.
 
S

SAm

thanx wayne,

i am familiar with both methods. will probably use the second. i was asking
wether someone has a better way to do it. i find it annonying. additionally,
i was wondering if there would be a way to populate dates.

thanks,

sam
 
W

Wayne Morgan

Personally, I type fast enough that I could make the 24 entries before I
made the routine to create them automatically, but you could create a small
routine to do that. Be aware, that if you opt for the list typed directly
into the combo box's Row Source, you'll have to open the form in design
mode, run the routine, then save changes as you close the form. To place the
list in a table would just be a matter of looping through the 24
possibilities, writing each one to a new record in the table, probably using
DAO.

Example (untested):
Dim db As DAO.Database, rst As DAO.Recordset, i As Integer
Set db = CurrentDb
Set rst = db.OpenRecordset("tblTimeTable", dbOpenDynaset)
With rst
For i = 0 To 23
.AddNew
![TimeField] = "#" & i & ":00#"
.Update
Next i
End With
rst.Close
Set rst = Nothing
Set db = Nothing
 
V

Van T. Dinh

Check Access Help on the CallBack function for another way. Whether it is
worth the effort or not ... depends on your personal viewpoint.

HTH
Van T. Dinh
MVP (Access)
 
Top