Help with SourceObject & Subform coding

S

Silvio

I posted this question in the wrong group before and should have been on this
group. Anyway ...

Back ground: I have a form with a subform in it. The main form works like a
side-menu bar to lunch different form in the subform. That is accomplished by
programmatically changing the subform “SourceObject†to the required forms.
Now I would like to take it one step further, I have some of these subforms
that have a “see detail†button in it. What that does, is to open a form for
the selected record and shows all that record details in a pup-up form. What
I would like to accomplish is to actually lunch that details form in my
subform by changing the SourceObject substitute the SUBFORM from products
list to product details and then have a button on the product details that
will bring you back to the product list (Web-like navigation process). Can it
be done?

The pieces of codes I have so far are:
To change the SourceObject from the main form
Me.[SubItems].[SourceObject] = "frmCalibTiming"


To open the view details in a separate form:
Dim strWhere As String
strWhere = "[ProductID]=" & Me![Product_ID]
DoCmd.OpenForm "frmEditCalibration", , , strWhere

I guess what I am trying to do is a combination of this codes. Any
step-by-step guide is appreciated.

Thank you,
Silvio
 
M

Marshall Barton

Silvio said:
I posted this question in the wrong group before and should have been on this
group. Anyway ...

Back ground: I have a form with a subform in it. The main form works like a
side-menu bar to lunch different form in the subform. That is accomplished by
programmatically changing the subform “SourceObject” to the required forms.
Now I would like to take it one step further, I have some of these subforms
that have a “see detail” button in it. What that does, is to open a form for
the selected record and shows all that record details in a pup-up form. What
I would like to accomplish is to actually lunch that details form in my
subform by changing the SourceObject substitute the SUBFORM from products
list to product details and then have a button on the product details that
will bring you back to the product list (Web-like navigation process). Can it
be done?

The pieces of codes I have so far are:
To change the SourceObject from the main form
Me.[SubItems].[SourceObject] = "frmCalibTiming"


To open the view details in a separate form:
Dim strWhere As String
strWhere = "[ProductID]=" & Me![Product_ID]
DoCmd.OpenForm "frmEditCalibration", , , strWhere


With a simple filter like "field = value", you can use the
LinkMaster/Child properties to make a subform sync to a
value in a (hidden?) main form text box (named txtLink).

The code could be along these lines:

With Me.SubItems
Me.txtLink = .Form.[Product_ID]
.SourceObject = "frmCalibTiming"
.LinkChildFields = "ProductID"
.LinkMasterFields = "txtLink"
End With

To run that kind of code from a subform, put it in a Public
procedure and call it with something like:
Parent.myproc

Note that (versions before A2007) there are issues with the
LinkMaster/Child properties when you set the SourceObject
property. The issues are generally seen with a bound main
form when Access would decide on its own to set the
properties to field names it thought should be automatically
linked. You probably won't run into it, but pay attention
to when/what you set/clear the LinkMaster/Child properties
even if you don't see a need for it.
 

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