Enter subform for new record

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

I would like to know how to enter the subform to enter a new record. I know
one option is to set the subform properties to Data Entry, but when I do that
it does not display the other records. I would like to see the other
records, but would like the cursor to star at the new record so that users
don't have to scroll down or click down. How can I accomplish this? Thank
you.
 
Kathy,
There's really no good event in the subform that you can hang the NewRec code on that
won't interfere with normal subform browsing, editing, deleteing, etc..
OnEnter, OnCurrent, OnClick, etc... are all problematic. While the code you want to
use works OK for single Main Forms, because you can hang it on the "once occuring" Open
event, it doesn't work well for continuous forms/subforms.

I would recommend showing the Navigation Buttons on your subform, and using the [>*]
button to access a new record in a long subform. That's really the best when all is said
and done...

Or, try some less used event such as...Dbl-Clicking ANY subform field subform causes a
Goto New record to occur. You'll have to code up all the fields to do so... so that's a
bit messy...

Or, create a cmdGoToNewRecord button on each subform record, caption it as
GoTo&NewRecord, and hide it. Now, whenever the user hits Alt-N they'll be sent to the New
record.
 
in the subform control's Enter event procedure, try the following code, as

On Error Resume Next

With Me!SubformControlName.Form
DoCmd.RunCommand acCmdRecordsGoToNew
End With

substitute the correct name of the subform *control*, of course, and make
sure that you're in the main form's Design view, clicking on the subform
control to select it, and adding the code to that control's Enter event
procedure.

hth
 
Beautiful!

I admit that I have no idea what I did (I've never done coding, just
macros), but I typed it in just as you said and it works beautifully. Thank
you.
 
you're welcome, and welcome to the power of VBA. ;)
i urge you to explore VBA and begin to use it; it'll take your database
development skills to a whole new level, and you'll love it!

hth
 
Back
Top