Open to new record in subform

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

Guest

I have a subform which I would like to open to a new record when the main form opens. I put a macro on the On Enter property of the subform that tells it to open the subform to a new record, but when I did this is told me that I was trying to open a record in a form that wasn't open... so... I put an open form in the macro. This opened the subform ONLY (not within the form) which is not my intent. How do I get the form to open, with the subform included, and have the subform open to a new record? I must be close?? I've referenced all my books and help, and I'm just not hitting on the right combination. HELP!!!
 
Kl,

It sounds like your original macro was not constructed correctly. I
think all you would need is a GoToRecord, New action. But I would
suggest the GotFocus event of the subform rather than the Enter event.

- Steve Schapel, Microsoft Access MVP
 
Not a bad suggestion, Gregory. Depends whether Kl wants to see his
existing subform records or not.

- Steve Schapel, Microsoft Access MVP
 
Let's see...

First, I did set the data entry property to Yes... I think that will be good... it is for me, we'll see what the users think.

Second, my macro did have the correct GoToRecord, New action, and I placed it on the GotFocus and it still told me that the subform was not open... who knows?

Third, now that I'm opening to a new record in the subform, all I'm trying to do is have the cursor open to the first field in the subform. I've put a macro on the OnOpen action in the subform (which works when I open just the subform alone) stating that it should GetFocus on that field (first it opens the subform, then I tell it to get focus on the field), but when I open the main form (with the subform embedded) it gives me an error stating that the subform is not open. It's not??? Then why can I see it and use it? My brain can't grasp it all! Do I need to put an action in the main form telling it to open the subform? I think I've tried that... I've tried everything but the right thing!

THANKS for your help!!!

----- Steve Schapel wrote: -----

Kl,

It sounds like your original macro was not constructed correctly. I
think all you would need is a GoToRecord, New action. But I would
suggest the GotFocus event of the subform rather than the Enter event.

- Steve Schapel, Microsoft Access MVP
 
Kl,

As regards the GoToRecord, New action, you must have something else in
the macro,... another action referring to the form you are using as
the subform, or else you are entering the something in the Object Type
and Object Names arguments of the GoToRecord action, which is not
correct.

And no, the form is not open. Only your main form is open. The main
form has a control on it, a subform control, where the form you are
using as the source object of the subform is being displayed... but
the form you are displaying as a subform on the main form is not open,
only the main form is. This is consistent with other aspects of form
behaviour. For example, a bound textbox displays data from a field in
a table, but the data is not on the form, the data is in the table and
the control on the form only acts as an avenue through which the data
is displayed.

By the way, I have since realised that I gave some incorrect
information to you before. Sorry. A subform does not have a GotFocus
event, so you were right in the first place to use the OnEnter event.

I think all you need is a macro with 2 actions:
GoToRecord, New
GoToControl, [NameOfFirstField]
and put this macro on the subform's OnEnter event property. I have
just tested this and it works for me... when you tab into the subform.
Obviously if you enter the subform by clicking the mouse, the position
of the mouse pointer will determine the focus.

- Steve Schapel, Microsoft Access MVP
 
Back
Top