Form/Subform Command Button & Links

LtlMsMagic

New member
Local time
Today, 01:38
Joined
Jan 9, 2012
Messages
2
I have a form that I would like to keep in "Continuous Form" view but also need a subform of sorts that can be opened with a DblClick or Command Button. I know technically you don't "open" a subform - it's linked to the parent table, however Access doesn't allow for the insertion of a subform if your parent form is in continuous view.

Is there a snippet of code that can open a form and define it as a child form and link master/child fields? Or any other method of opening a form with a command button and have it linked to the parent table by a PK field?
 
Thanks for the reply! The code gets me halfway where I need to be. :)

I apologize for not being more clear. Sometimes describing the issue in writing is more difficult than the issue itself. :)

The second form I want to open will be used primarily to make changes to the specified record. For example; my form shows a list of products in continuous form view and I wish to dbl click on a specific record and have the new entry form appear to make changes to the quantity. Those changes are stored in a separate "Changes" table. There may or may not be existing changes for that product in the "changes" table - either way I would still like the StockID number to populate in the second form. In short, I need it to function as though it were a true SubForm.
 
So after you've passed the criteria and the form loads, you do this in the Load event of the form:
Code:
If Me.Recordset.RecordCount = 0 Then
    DoCmd.GoToRecord acCmdRecordsGoToNew
    Me.[COLOR=Red]ID[/COLOR] = Forms![COLOR=Red]FormName[/COLOR]![COLOR=Red]ID[/COLOR]
    Me.[COLOR=Red]Quantity[/COLOR] = Forms![COLOR=Red]FormName[/COLOR]![COLOR=Red]Quantity[/COLOR]
End If
The code is pretty straightforward. Just replace amend the red bits.

Forms!FormName refers to the form where the button was clicked.
 

Users who are viewing this thread

Back
Top Bottom