datasheet view form open NEW

L

lmv

I have a datasheet form when it opens I'd like it to
setfocus at the "Enter NEW Area HERE"(defaultvalue of txtAreaName)
new record instead of the first record on the list.

I cannot just change it to data entry to YES because then
I can't see all records which I want to see.

Is there a way to setfocus to the new record in datasheet view?

Thanks
 
J

John B. Smotherman

If you're opening the form in datasheet view in code, you can do it in the
DoCmd.OpenForm statement by passing an openarg and testing for that argument
in the OnLoad or OnOpen event in the form. If the argument is present then
use
"DoCmd.RunCommand acCmdRecordsGoToNew".

The advantage to this method is it gives you the option to open the form and
set the focus to a new record, or to open the form at the beginning record,
but there's more work involved and it requires a slightly greater knowledge
of Access.

If you're not opening the form via code, that is if you're selecting the
form through the database window, you can add a macro to the form's design
and do it that way. Open the form in design view, and in the properties
window select the "event" tab. For the OnOpen event, create a macro that
calls GoToRecord, and select "New" as the record to go to.

The advantage to this method is it's easier to do, but it will always open
the form at a new record. You no longer have the option of what record to
start at.

hth.
 
L

lmv

YOU'RE BRILLIANT! THANKS!

John B. Smotherman said:
If you're opening the form in datasheet view in code, you can do it in the
DoCmd.OpenForm statement by passing an openarg and testing for that argument
in the OnLoad or OnOpen event in the form. If the argument is present then
use
"DoCmd.RunCommand acCmdRecordsGoToNew".

The advantage to this method is it gives you the option to open the form and
set the focus to a new record, or to open the form at the beginning record,
but there's more work involved and it requires a slightly greater knowledge
of Access.

If you're not opening the form via code, that is if you're selecting the
form through the database window, you can add a macro to the form's design
and do it that way. Open the form in design view, and in the properties
window select the "event" tab. For the OnOpen event, create a macro that
calls GoToRecord, and select "New" as the record to go to.

The advantage to this method is it's easier to do, but it will always open
the form at a new record. You no longer have the option of what record to
start at.

hth.
 

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