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]