Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
Home
Discussion GroupsFormsForms ProgrammingQueriesModules / DAO / VBAReports / PrintingMacrosDatabase DesignSecurityConversionImporting / LinkingSQL Server / ADPMultiuser / NetworkingReplicationSetup / ConfigurationDeveloper ToolkitsActiveX ControlsNew UsersGeneral 1General 2
Access DirectoryToolsTutorialsUser Groups
Related Topics
SQL ServerOther DB ProductsMS OfficeMore Topics ...

MS Access Forum / General 2 / July 2007

Tip: Looking for answers? Try searching our database.

Run Time error 2467 when trying to add new record from a parent fo

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Access Help - 20 Jul 2007 05:52 GMT
Hi all
I am trying to add a new record from the a parent form to child form, but
when I click the button in get the following "expression to you entered
refers to an object that is closed or doesn't exist"

here is my code
Private Sub CreateNewIssue_Click()
   With Me!mycollection (childford)
      .SourceObject = "index" (parent form)
      .SetFocus
      .Form!mycollection.SetFocus
   End With

   DoCmd.GoToRecord , , acNewRec
End Sub

Please help
Thanks
Hunter57 - 20 Jul 2007 15:18 GMT
Hi,

Is there any particular reason you want to use code instead of an append
query?

Here is an example of using an append query:

Private Sub YourButtonName_Click()

   DoCmd.SetWarnings False     ' Disable Access Warnings
   DoCmd.OpenQuery "qryAPersonIDtotblMembers"
   DoCmd.SetWarnings True     ' Enable Access Warnings

   DoCmd.OpenForm "YourFormName"
   DoCmd.GoToRecord , , acLast

End Sub

Regards,
Hunter57

> Hi all
> I am trying to add a new record from the a parent form to child form, but
[quoted text clipped - 14 lines]
> Please help
> Thanks
Tony Toews [MVP] - 21 Jul 2007 00:25 GMT
>Here is an example of using an append query:
>
[quoted text clipped - 8 lines]
>
>End Sub

You are strongly urged to use error handling, although I do realize
this is sample code.

I prefer, if DAO, to use Currentdb.Execute strSQL,dbfailonerror
command instead of docmd.runsql.  For ADO use
CurrentProject.Connection.Execute strCommand, lngRecordsAffected,
adCmdText  

If you're going to use docmd.setwarnings make very sure you put the
True statement in any error handling code as well.   Otherwise weird
things may happen later on especially while you are working on the
app.  For example you will no longer get the "Do you wish to save your
changes" message if you close an object.  This may mean that unwanted
changes, deletions or additions will be saved to your MDB.

Also performance can be significantly different between the two
methods.  One posting stated currentdb.execute took two seconds while
docmd.runsql took eight seconds.  As always YMMV.

Tony
Signature

Tony Toews, Microsoft Access MVP
  Please respond only in the newsgroups so that others can
read the entire thread of messages.
  Microsoft Access Links, Hints, Tips & Accounting Systems at
http://www.granite.ab.ca/accsmstr.htm
  Tony's Microsoft Access Blog - http://msmvps.com/blogs/access/

 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2009 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.