View Single Post
  #8  
Old February 4th, 2010, 06:52 PM posted to microsoft.public.access.forms
Dirk Goldgar
external usenet poster
 
Posts: 2,529
Default Setting subform to add mode while main form is in edit mode

"John W. Vinson" wrote in message
...
On Thu, 4 Feb 2010 05:49:55 -0800 (PST), Justin
wrote:

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!



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)