Default to Date derived from Query is not working...HELP!

  • Thread starter Thread starter Andre Laplume via AccessMonster.com
  • Start date Start date
A

Andre Laplume via AccessMonster.com

I have an Acces form. I want a box on it that defaults to a particular
date but which also allows the user to type any date he/she wants.

I have a query that returns the single date I'd like the default to be.

The best I can do(so far) is either have a text box that allows the user to
enter a date OR have a combo box that defaults to NULL but also has the
desired default date as the second date in its list. Again, it is pulling
this default date via a query execution.

How do I get the best of both worlds. Should I have a text box? A combo
box? I am confused as to what properties I need to set.


THANKS!!!!
 
Andre said:
I have an Acces form. I want a box on it that defaults to a
particular date but which also allows the user to type any date
he/she wants.

I have a query that returns the single date I'd like the default to
be.

Why have the query return the date for the default? What is the expression
you use - you can likely use the same expression as the default on the
control on the form.
 
More info: Users run monthly reports for which they can specify a begin
and end date. The 'latest' end date though can only be the last day of the
prior month. That is when our warehouse will have been last refreshed.

The desire was set to set up a form with a box (text box?) for begin date
and end date with end date defaulting to the last day of the prior month
thus indicating to the user that they can only pull data at most, thru that
date. The user would of course be able to change the date to some date
prior if desired.

We have a 'calendar' table that when queried easily returns the date of the
last day of the last month.

I can NOT get the text box 'default' property to execute this query. I CAN
get 'combo' box to execute this row source property: SELECT
[qryGetEndDatePriorMonth].[MaxOfDate] FROM [qryGetEndDatePriorMonth] ORDER
BY [MaxOfDate]. When the form is opened this results in a dropdown box
being shown whose default is blank. If you click the down arrow however
you see the result of the above mentioned query.

What I really want is the query result as the default. Also, it feels like
this should be a text box rather than a combo box.

Hope I have not confused the situation.
 
Put this as the default value for the control End Date on
the form
=DateSerial(Year(Date()),Month(Date()),1)-1

Chris
-----Original Message-----
More info: Users run monthly reports for which they can specify a begin
and end date. The 'latest' end date though can only be the last day of the
prior month. That is when our warehouse will have been last refreshed.

The desire was set to set up a form with a box (text box?) for begin date
and end date with end date defaulting to the last day of the prior month
thus indicating to the user that they can only pull data at most, thru that
date. The user would of course be able to change the date to some date
prior if desired.

We have a 'calendar' table that when queried easily returns the date of the
last day of the last month.

I can NOT get the text box 'default' property to execute this query. I CAN
get 'combo' box to execute this row source property: SELECT
[qryGetEndDatePriorMonth].[MaxOfDate] FROM
[qryGetEndDatePriorMonth] ORDER
BY [MaxOfDate]. When the form is opened this results in a dropdown box
being shown whose default is blank. If you click the down arrow however
you see the result of the above mentioned query.

What I really want is the query result as the default. Also, it feels like
this should be a text box rather than a combo box.

Hope I have not confused the situation.
 
Sorry it should be this as the default value

=DateSerial(Year(Date()),Month(Date()),0)

chris
-----Original Message-----
More info: Users run monthly reports for which they can specify a begin
and end date. The 'latest' end date though can only be the last day of the
prior month. That is when our warehouse will have been last refreshed.

The desire was set to set up a form with a box (text box?) for begin date
and end date with end date defaulting to the last day of the prior month
thus indicating to the user that they can only pull data at most, thru that
date. The user would of course be able to change the date to some date
prior if desired.

We have a 'calendar' table that when queried easily returns the date of the
last day of the last month.

I can NOT get the text box 'default' property to execute this query. I CAN
get 'combo' box to execute this row source property: SELECT
[qryGetEndDatePriorMonth].[MaxOfDate] FROM
[qryGetEndDatePriorMonth] ORDER
BY [MaxOfDate]. When the form is opened this results in a dropdown box
being shown whose default is blank. If you click the down arrow however
you see the result of the above mentioned query.

What I really want is the query result as the default. Also, it feels like
this should be a text box rather than a combo box.

Hope I have not confused the situation.
 
Much Simpler than my method...THANKS!

PS:

What is the simplest method to get forms to open 'maximized' in Access? I
am guessing it is finicky about how to set this up.
 
Andre said:
More info: Users run monthly reports for which they can specify a
begin and end date. The 'latest' end date though can only be the
last day of the prior month. That is when our warehouse will have
been last refreshed.

We have a 'calendar' table that when queried easily returns the date
of the last day of the last month.

I can NOT get the text box 'default' property to execute this query.
I CAN get 'combo' box to execute this row source property: SELECT
[qryGetEndDatePriorMonth].[MaxOfDate] FROM [qryGetEndDatePriorMonth]
ORDER BY [MaxOfDate].

You could use
=DMax("MaxOfDate","qryGetEndDatePriorMonth") as the default or better,

=DateAdd("m", 1, DateSerial(Year(date()), month(date())-1, 1))-1
 
On the on load event of the form put
docmd.maximize
When I start my application I want it maximized so I put on
the first form
DoCmd.RunCommand acCmdAppMaximize
docmd.maximize

Chris
 
Back
Top