The value of a field from a subform of another form?

PC User

Registered User.
Local time
Today, 12:00
Joined
Jul 28, 2002
Messages
193
I'm trying to link a form to open when a field is double clicked on the main form. When the form is opened it should open to the current record that is present on the subform.

In the opening form, I tried using a parameter query as the record source that references the current ID field on the subform. I think my problem is with referencing the value in the subform from the form that I am opening. I've read the FAQ for referencing to help me and so far this is what I've got as a parameter in the query for referencing is [Forms]![frmMainEntry].[Forms]![fsubWOArchive]![TrackingID]

The subform control on the main form is fctlWOArchive
The subform itself is fsubWOArchive

How do I get the value of the TrackingID field from a subform of another form?

Thanks,
PC
 
Not sure what FAQ you're referring to, but you may want to check it again. That syntax is off. Here's a good reference:

http://www.mvps.org/access/forms/frm0031.htm

You could also try the "Build" feature by right clicking in the criteria section of the query in design view. Navigating to the appropriate form/control will build the correct reference.
 
Thanks for the link. I've see that chart and the explanation from http://www.mdbmakers.com/forums/showthread.php?t=2650 All the charts from various forums describe referencing between main forms and subforms, but I'm looking for the way to reference from outside the main form and sub form to get the value into a popup form.

I have a popup form with the same record source as the main form and subform; however, the criteria in the TrackingID field of the record source of the popup form needs to be the same as the current TrackingID of the subform in the main form.
1) Do I reference the field in the subform directly?
2) Do I reference the field through the subform control in the main form?
3) Either way, what is the correct syntax?

I hope my verbal descriptions make sense. I don't see any explainations of this in either the link that you mentioned or the one that I show above.

Thank,
PC
 
It was on the link I gave you, shown here:
 

Attachments

  • forms.JPG
    forms.JPG
    45.4 KB · Views: 1,373
How bout trying this.... Your opening a seperate form correct? On the command button to open the seperate form (On Click event) do something like this................

Private Sub CommandButton_Click()


Dim stDocName As String
Dim stLinkCriteria As String

stDocName = "NewForm"

stLinkCriteria = "[TrackingID]=" & Me![TrackingID]
DoCmd.OpenForm stDocName, , , stLinkCriteria

Exit_CommandButton_Click:
Exit Sub
 
Thanks Paul,

I still had to do a little testing. The reference is to the subform control on the main form and not directly to the subform. It now works.

Correct:
[Forms]![frmMainEntry]![fctlWOArchive].[Form]![TrackingID]

Not Correct:
[Forms]![frmMainEntry]![fsubWOArchive].[Form]![TrackingID]

Thanks,
PC
 

Users who are viewing this thread

Back
Top Bottom