Setting subform to add mode while main form is in edit mode

  • Thread starter Thread starter Justin
  • Start date Start date
J

Justin

Is it possible to have the subform on a main form open in add mode
while the main form is in edit mode?
I have a main form that shows the first and last name of my drivers
while the subform is for entering a date and number of hours on duty
for that date. The subform is beginning to have a large number of
entries and I have to scroll down to the last entry to begin entering
data.

Thanks for your help

Justin
 
Yes, just set the subform's Data entry property to Yes.
This sort of thing you can just try for yourself by changing the setting to
the one you want.
Then test the form/subform to see if it works the way you want.

Jeanette Cunningham MS Access MVP -- Melbourne Victoria Australia
 
Is it possible to have the subform on a main form open in add mode
while the main form is in edit mode?
I have a main form that shows the first and last name of my drivers
while the subform is for entering a date and number of hours on duty
for that date. The subform is beginning to have a large number of
entries and I have to scroll down to the last entry to begin entering
data.

Thanks for your help

Justin

Sure. Jeanette's suggestion of "Data Entry" will work.

However, it has the disadvantage that if Data Entry is set to Yes, then that's
ALL you can do - add new records - and you won't see any existing ones.

As an alternative, you can use the Load event of the subform to jump to the
new record:

Private Sub Form_Load()
DoCmd.GoToRecord, , acNewRecord
End Sub
 
Sure. Jeanette's suggestion of "Data Entry" will work.

However, it has the disadvantage that if Data Entry is set to Yes, then that's
ALL you can do - add new records - and you won't see any existing ones.

As an alternative, you can use the Load event of the subform to jump to the
new record:

Private Sub Form_Load()
DoCmd.GoToRecord, , acNewRecord
End Sub

Your method is what I was shooting for John. I had looked at
Jeanette's method before, but wasn't sure that it was what I really
wanted. Thanks to the both of you for helping to educate another
novice.

Justin
 
Your method is what I was shooting for John. I had looked at
Jeanette's method before, but wasn't sure that it was what I really
wanted. Thanks to the both of you for helping to educate another
novice.

Justin

Guess I should have tried it before I responded. I put your code in
the Load event of the subform and it hangs up. Should this code go
into another event in addition to the load event? I copied the code
and pasted it into the event and it didn't give an error until I tried
to open the main form. The run-time error 2105 comes up saying that
"you can't go to the specified record".
Thanks again for you help.

Justin
 
Guess I should have tried it before I responded. I put your code in
the Load event of the subform and it hangs up. Should this code go
into another event in addition to the load event? I copied the code
and pasted it into the event and it didn't give an error until I tried
to open the main form. The run-time error 2105 comes up saying that
"you can't go to the specified record".
Thanks again for you help.

My mistake! I didn't test it myself... that will happen (I'm guessing) if
there are no records in the subform at all. Let me think about this and I'll
get back to you - or does anyone else have a solution handy? I know this has
been done!
 
My mistake! I didn't test it myself...  that will happen (I'm guessing)if
there are no records in the subform at all. Let me think about this and I'll
get back to you - or does anyone else have a solution handy? I know this has
been done!

There are already records in the subform, so I don't think that's it.
Until later, thanks.

Justin
 
John W. Vinson said:
My mistake! I didn't test it myself... that will happen (I'm guessing) if
there are no records in the subform at all. Let me think about this and
I'll
get back to you - or does anyone else have a solution handy? I know this
has
been done!


Current event of the main form ought to do it. E.g,

Private Sub Form_Current()

Me.sfSubformName.Form.Recordset.AddNew

End Sub

(Access 2000 or later)
 
Current event of the main form ought to do it.  E.g,

    Private Sub Form_Current()

        Me.sfSubformName.Form.Recordset.AddNew

    End Sub

(Access 2000 or later)

--
Dirk Goldgar, MS Access MVP
Access tips:www.datagnostics.com/tips.html

(please reply to the newsgroup)

I placed this line of code in the Form Load and Form Current and it
seems to work like I want it to.

DoCmd.GoToRecord , , acNewRec

Thanks for all the help guys. Maybe one day I can give back to the
group as well.

Justin Thomas
 
Back
Top