On Form Open Go to today

I

Iram

Hello.
I am trying to add something to a Form's Events "On Open".
When I open a Form I need the form to go to todays date or current date.
On the "On Open" field I have tried stuff like =Date=Now()
The name of the date field is Date. I have already appended dates from
1-9-07 to 1-1-2030.

Actually I need the form to do two things, Maximize the form and go to
todays or current date.
I have already created a macro to maximize the screen and I had the macro on
the On Open field but now that I need the form to do two things should I move
the maximize macro to On Load and put the new code (to go to current date) on
the On Open?

What code should I put? i.e. =Now()

Your help is greatly appreciated.

Thanks.
Iram/mcp
 
J

John W. Vinson

Hello.
I am trying to add something to a Form's Events "On Open".
When I open a Form I need the form to go to todays date or current date.
On the "On Open" field I have tried stuff like =Date=Now()
The name of the date field is Date.

I'd suggest that you change it. Date is a reserved word for the
builtin Date() function, and Accss WILL get confused!
I have already appended dates from
1-9-07 to 1-1-2030.

Ummm... that's actually a Very Bad Idea, most likely. Inserting 8393
empty "placeholder" records wastes a lot of space, and gives you NO
useful information. It sounds to me like you simply want today's date
to be inserted in a date field (RecordDate say) at the time that you
create a new record; you can do this by simply setting the
DefaultValue property of either the table field or a form control (not
both!) to Date().
Actually I need the form to do two things, Maximize the form and go to
todays or current date.
I have already created a macro to maximize the screen and I had the macro on
the On Open field but now that I need the form to do two things should I move
the maximize macro to On Load and put the new code (to go to current date) on
the On Open?

A Macro can have many steps. You don't need to have just one... but,
as I say, you don't NEED one.
What code should I put? i.e. =Now()

Now() is a function which returns the current date and time accurate
to the nearest second; it will NOT "go to" a record. But again - *your
table structure is flawed* and (unless you can explain some reason why
you need all these dates prefilled) it should not be necessary to do
it this way at all.

John W. Vinson [MVP]
 
F

fredg

Hello.
I am trying to add something to a Form's Events "On Open".
When I open a Form I need the form to go to todays date or current date.
On the "On Open" field I have tried stuff like =Date=Now()
The name of the date field is Date. I have already appended dates from
1-9-07 to 1-1-2030.

Actually I need the form to do two things, Maximize the form and go to
todays or current date.
I have already created a macro to maximize the screen and I had the macro on
the On Open field but now that I need the form to do two things should I move
the maximize macro to On Load and put the new code (to go to current date) on
the On Open?

What code should I put? i.e. =Now()

Your help is greatly appreciated.

Thanks.
Iram/mcp


Code the Form's Open event:

DoCmd.Maximize
Me![YourDateField].SetFocus
DoCmd.FindRecord Date, acEntire, , , , acCurrent, True

Note: Date is a reserved Access/VBA/Jet word and should not be used as
a field name.
For additional reserved words, see the Microsoft KnowledgeBase article
for your version of Access:

109312 'Reserved Words in Microsoft Access' for Access 97
209187 'ACC2000: Reserved Words in Microsoft Access'
286335 'ACC2002: Reserved Words in Microsoft Access'
321266 'ACC2002: Microsoft Jet 4.0 Reserved Words'

For an even more complete list of reserved words, see:
http://www.allenbrowne.com/AppIssueBadWord.html
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top