Modify Code on Form

N

NEWER USER

I have a subform on a form and when Double clicking on a field, another form
opens and displays the same number on the newly opened form as the subform.

Private Sub Number_DblClick(Cancel As Integer)
On Error GoTo Number_DblClick_Err
Dim strDoc As String
strDoc = "frmProductSync"
'Synchronize Number field; frmOrderEntryList to frmProductSync
DoCmd.OpenForm strDoc, acNormal, "",
"Number=Forms!frmOrderEntry!fsubOrderEntryList.Form!Number", , acNormal
DoCmd.GoToControl "Number"

Number_DblClick_Exit:
Exit Sub

Number_DblClick_Err:
MsgBox Err.Description
Resume Number_DblClick_Exit

End Sub

This works very well.

I would like to place this subform on several other forms and still have the
ability to open the link form and display same number. How might I re-work
my code in referencing the main form so I don't have to create several exact
subforms (named differently) when changing the main form reference. Example:

"Number=Forms!frmOrderEntry!fsubOrderEntryList.Form!Number", , acNormal

"Number=Forms!frmGross Profit!fsubOrderEntryList1.Form!Number", , acNormal

"Number=Forms!frmInterchange!fsubOrderEntryList2.Form!Number", , acNormal

Any help appreciated.

Thanks
 
D

Daryl S

Newer User -

Look up OpenArgs in Microsoft Help. This lets you send a value to the form
being opened (in your case, the sending form would pass in the number). In
the form being opened, you will display the OpenArgs value in the form.

That should get you started.
 
N

NEWER USER

OpenArgs did exactly as I wanted. Thanks again for getting me pointed in the
right direction. Happy Holidays!
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top