"GoTo New Record"

  • Thread starter Thread starter Robin Chapple
  • Start date Start date
R

Robin Chapple

I have a form in datasheet view which when opened I need the focus to
go to a new record.

I already have a command "GoTo Field".

How do I do that?

Thanks,

Robin Chapple
 
Robin,

Open the form in design view, and select the form object (Edit > Select
Form). Display the properties window (if not already open) by Vew >
Properties, select tab Events, place the cursor in the box next to On
Open and click the little button with the ellipsis sign (...) that
appears on the right; select Macro Builder, give the macro a meaningful
name (so you can tell what it is when you see it later) and add a single
action to it, GoToRecord, with argument Record set to New. Save and
return to the form. The job is done.

HTH,
Nikos
 
Just out of curiosity, why a macro instead of a VBA procedure? There seems
to be some difference between the two, but I have never quite sorted out what
it is.
 
Hi Bruce,

A macro in this case, simply because the OP occurred in the
GettingStarted NG, and the question itself justifies the selection of NG
too... new users seem to feel more comfortable with Macros.

In my experience, the difference is that code provides far more
flexibility and control, at the cost of a higher expertise level
requirement. I think once you cross the line, there's no turning back!

Regards,
Nikos
 
Thanks for the reply. A book I read when I was first using Access said that
as of Access 2000 VBA procedures were the way to go, although macro support
was still available. By using VBA procedures from the beginning I guess I
jumped in the deep end, but certainly not for the first time.
 
Nikos,

Thanks that worked for the first member. When I selected the next
member I had to scroll again.

Now this may be associated with the fact that the form is a sub form
with members called from a combo box on the main form.

Robin
 
Nikos,

I have been using VBA for several years but still consider myself a
"getting started" customer because of my lack of knowledge.

When I get this macro working I will convert it to VBA.

Robin
 
Now this may be associated with the fact that the form is a sub form
with members called from a combo box on the main form.
Yes, that's what makes the difference! We have been using the Form_Open
event for a subform, which obviously only opens once, so the event won't
fire next time.
In light of the new information, you need to use a different event to
trigger the action, and thst's the combo's On Change event; since you're
familiar with VBA code, put this in the combo's On Change event:

Me.YourSubformNameHere.SetFocus
DoCmd.GoToRecord , , acNewRec

This should do the trick.

Regards,
Nikos
 
Bruce,

Though I'm still on A2K myself, I believe macros are still there in
A2K3, and for a good reason in my opinion: they provide a far easier
entry point to automation for the novice user... not everyone jumps in
the deep like you! I'd been using macros for a long time before I
jumped. Now that I have, i would also say that VBA is the way to go
(eventually), but for different reasons, not for discontinued support
(if that's the case).

Regards,
Nikos
 
I have been using VBA for several years but still consider myself a
"getting started" customer because of my lack of knowledge.
I guess that makes you a rare exception :-)

Nikos
 
Nikos,

I supplied some wrong information. I am not using a combo box I am
using a List Box and there in no "On Change" event.

Is there another option please?

Robin
 
I've settled this one by changing to a combo box and using your code.

Bingo! she's a good one.

Thanks very much

Robin
 
I've settled this one by changing to a combo box and using your code.

Bingo! she's a good one.

Thanks very much

Robin
 
Robin,

Sorry for the delay, I was away for a few days. Glad you worked it out.
You could have done it just as well with the listbox, using the On Click
event instead.

Nikos
 
Nikos,

Thanks for that further information. I will take that option because I
like the way that the list box displays the list without the need for
a click.

Robin
 
Back
Top