Ask user to enter month then query for that month

  • Thread starter Thread starter AL Rios
  • Start date Start date
A

AL Rios

I want to ask a user to enter month required for the report. Then provide
that paramater in a form.

The problem I have is the field I am using in the data datebase is date as
1/18/2007

indicating 1 as Jan , 18 as 18th of Jan and years as 2007.

I want the user to enter October for month. The return the results in forms
and print the results.

Thank You..

AL
 
AL said:
I want to ask a user to enter month required for the report. Then
provide that paramater in a form.

The problem I have is the field I am using in the data datebase is
date as 1/18/2007

indicating 1 as Jan , 18 as 18th of Jan and years as 2007.

I want the user to enter October for month. The return the results
in forms and print the results.

Thank You..

AL

Will there ever be more than one year's worth of data? If so, do you want ALL
Octobers or just October for the current year (or some other year)?
 
Just for the current year...

Thank You..

AL



Rick Brandt said:
Will there ever be more than one year's worth of data? If so, do you want ALL
Octobers or just October for the current year (or some other year)?
 
AL said:
Just for the current year...

What I would do then is provide a ComboBox that has two columns. The hidden
bound column would hold the numeric value for the month and the displayed column
would contain the name of the month) Then the code for opening your report
could be like...

DoCmd.OpenReport "ReportName", acViewPreview,,"DateField >=
DateSerial(Year(Date()), Forms!FormName!ComboBoxName, 1) AND DateField <
DateSerial(Year(Date()), Forms!FormName!ComboBoxName + 1, 1)
 
Another way you might consider is to place this as the date criteria for your
query:
Between DateValue([enter mm/yyyy]) And DateAdd("m",1,DateValue([enter mm/yyyy]
)-1)

The user will be prompted to enter month & year (e.g. 11/2007) and the
recordset will be restricted to just those records in the target month/year.

HTH - Bob
 
raskew said:
Another way you might consider is to place this as the date criteria
for your query:
Between DateValue([enter mm/yyyy]) And DateAdd("m",1,DateValue([enter
mm/yyyy] )-1)

The user will be prompted to enter month & year (e.g. 11/2007) and the
recordset will be restricted to just those records in the target
month/year.

HTH - Bob

That will not work for the end date if the table's values include non-midnight
times though.
That is why I never use BETWEEN for date values.
 
Back
Top