Combo box drop down data for/of 30 days date

  • Thread starter Thread starter Np
  • Start date Start date
N

Np

Due to fast and hudge data entry I am looking for a
soltuion that I have a combo box, which is a date
datatype, in which every time I have to type date, which
is of any day of current month only.

Therefore, I will make my datefield change to Combo box
and in that combobox when I make it drop down it should
show me all the dates of the current month for example,
please note the below :

When combo box drop down, the data should show as :

01-09-2004
02-09-2004
03-09-2004
and so on till, I mean till end date of the current month
only.
30-09-2004

By this I will get a help, that I dont have type complete
date and I can just select it.

Note: This form and all its control is based on a table.

Please advise.
 
Np,

Why go through all that jazz? Access offers two ActiveX controls, namely
Calendar Control and Microsoft Date and Time Picker, which you can use to do
exactly what you want! Try them out both to see which suits you better by
inserting them in a blank test form: Insert > ActiveX Control ...
Just note that you will have to use a simple piece of code behind a suitable
form event, such as On Current, to make the control default in the current
date. If the control is bound, that should only happen on new records, so
the code would be:
If Me.NewRecord Then
Me.ActiveXControlName = Date()
End If

If the control is unbound, you should do that always, so simply:

Me.ActiveXControlName = Date()

Just change ActiveXControlName to the actual anme of the control.

HTH,
Nikos
 
Attn:. Mr. Nikos

Sir, Its my need to do that, because I cannot add any
thing additional on the form, Its a tabular type of form.
Actually, I have to feed about 100 of records every day,
out of which One field is a date field and the date is of
current month only, while posting the records, In one day
I get all dates of the month, about 20 are of different
date and 20 are of different, like this. I was trying to
escape 100 times typing the date, therefore, I was
thinking that I will make it a combo box from text box and
make such a attachment record source that It will show me
a drop down of complete date list from where I can select
any of the date by mouse.

Please, If you can ,suggest me any method.
regards.
 
NP,

Ok, if that's how you want it; my proposed solution requires a lookup table
to hold the current month's dates, table name Current_Month_Dates, one date
type field called fldDate.
I have assumed the name of the combo on your form to be cboDate.
The idea is to fire a piece of VBA code on Form Open, which will clear the
existing records in the table and re-populate it wih the dates in the
current moth. The code looks something like:

Private Sub Form_Open(Cancel As Integer)
Dim strSQL As String
Dim rst As DAO.Recordset
strSQL = "DELETE * FROM Current_Month_Dates"
CurrentDb.Execute strSQL
Set rst = CurrentDb.OpenRecordset("Current_Month_Dates")
vDate = Date - Day(Date) + 1
rst.AddNew

Do
rst.Fields(0) = vDate
If Month(vDate) <> Month(Date) Then Exit Do
rst.Update
vDate = vDate + 1
rst.AddNew
Loop

rst.Close
Set rst = Nothing
Me.cboDate.RowSource = "SELECT fldDate FROM Current_Month_Dates"

End Sub

It requires a Microsoft DAO 3.xx Object Library reference to run.

Still, I'm not convinced this is the best solution; combos with ca. 30 rows
are not very convenient when the one you are looking for is not visible when
you open them, and you have to scroll down. You could still use a DT Picker
if you displayed continuous forms instead of datasheet and it would be
rather more convenient.
By the way, if dates repeat for twenty consecutive records or so, and then
change and repeat for another twenty and so on, I wouldn't use combos or DT
pickers or anything at all! I would just manually enter a date, and then in
all the subsequent records it is repeated just use Ctrl+' on my keyboard as
I type to repeat the previous record's entry in the particular
field/control. I'll bet you that's the fastest way when doing data entry on
the keyboard. Have you tried that?

HTH,
Nikos
 
Back
Top