Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chris Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Open Form in acFormAdd with Pre-Populated Field

Status
Not open for further replies.

dusterb

IS-IT--Management
Jun 13, 2005
21
US
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
 
Search Access Help for the OpenForm method and take a look at the OpenArgs parameter. You could use this to pass a value to the form in the manner you require.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top