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 / Forms Programming / November 2005

Tip: Looking for answers? Try searching our database.

Linking Two Forms Programatically

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Rich F - 23 Nov 2005 01:05 GMT
O.k., it's late and I simply cannot remember how to set this up
correctly...I've got a form (Applicants) with a button that opens another
form (References) to the linked records on the Applicants form--did that part
with no problem.  However the linked field doesn't auto-populate if there are
no records in the References table corresponding to the Applicant table.  
What, o, what piece of code do I need to be able to enter records into the
References form when there are no previous records with the Applicant ID in
the Reference form/table?

Hope that made sense--just in case, I put the code I'm using below:

Private Sub btnOPenfrmReference_Click()
On Error GoTo Err_btnOPenfrmReference_Click

   Dim stDocName As String
   Dim stLinkCriteria As String

   stDocName = "frmReference"
   
   stLinkCriteria = "[RefPos]=" & Me![sfmPos]![PosID]
   DoCmd.OpenForm stDocName, , , stLinkCriteria

Exit_btnOPenfrmReference_Click:
   Exit Sub

Err_btnOPenfrmReference_Click:
   MsgBox Err.Description
   Resume Exit_btnOPenfrmReference_Click
   
End Sub
Signature

Rich F

Marshall Barton - 23 Nov 2005 01:17 GMT
>O.k., it's late and I simply cannot remember how to set this up
>correctly...I've got a form (Applicants) with a button that opens another
[quoted text clipped - 17 lines]
>    stLinkCriteria = "[RefPos]=" & Me![sfmPos]![PosID]
>    DoCmd.OpenForm stDocName, , , stLinkCriteria

DoCmd.OpenForm stDocName, , , stLinkCriteria, _
            OpenArgs:= Me![sfmPos]![PosID]

Then in theRefPos form's BeforeInsert event:
    Me.posidfield = Me.OpenArgs

Signature

Marsh
MVP [MS 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



©2008 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.