I've read a few posts on this topic and think I have it right, but obviously not. The form opens in add mode, but the field isn't populated. I'm hoping somebody can get me going in the right direction.
I have a subform with a combo box field called 'CompanyID' and a button called 'Cmd_AddCompany'. On click I'm looking to open the form Company in record add mode and have the field called 'Name' pre-populated with the value from 'CompanyID'. Here's what I have:
Private Sub Cmd_AddCompany_Click()
Dim stDocName As String
Dim stLinkCriteria As String
stDocName = "Company"
stLinkCriteria = "[Name]=" & Me![CompanyID]
DoCmd.OpenForm stDocName, , , stLinkCriteria, acFormAdd
End Sub
I have a subform with a combo box field called 'CompanyID' and a button called 'Cmd_AddCompany'. On click I'm looking to open the form Company in record add mode and have the field called 'Name' pre-populated with the value from 'CompanyID'. Here's what I have:
Private Sub Cmd_AddCompany_Click()
Dim stDocName As String
Dim stLinkCriteria As String
stDocName = "Company"
stLinkCriteria = "[Name]=" & Me![CompanyID]
DoCmd.OpenForm stDocName, , , stLinkCriteria, acFormAdd
End Sub