issue with the referring subform control in sub form criteria

siamandm
BronzeLounger
Posts: 1227
Joined: 01 May 2016, 09:58

issue with the referring subform control in sub form criteria

Post by siamandm »

Hello All

why this referring control in the sub form not work as below

Code: Select all

[forms]![MainForm]![subForm01]![subForm02].[form]![cbonameID]
i have tried this as well

Code: Select all

[Forms]![MainForm].[Form]![subFrom01].[Form]![subform02].[Form]![cboTestNameID]
any suggestions please?
Regards

User avatar
HansV
Administrator
Posts: 78500
Joined: 16 Jan 2010, 00:14
Status: Microsoft MVP
Location: Wageningen, The Netherlands

Re: issue with the referring subform control in sub form criteria

Post by HansV »

Try

[Forms]![MainForm]![subForm01]![subForm02]![cbonameID]
Best wishes,
Hans

siamandm
BronzeLounger
Posts: 1227
Joined: 01 May 2016, 09:58

Re: issue with the referring subform control in sub form criteria

Post by siamandm »

still same issue :(

User avatar
HansV
Administrator
Posts: 78500
Joined: 16 Jan 2010, 00:14
Status: Microsoft MVP
Location: Wageningen, The Netherlands

Re: issue with the referring subform control in sub form criteria

Post by HansV »

Make sure that you use the names of the subforms as controls on their parent form. That is not necessarily the same as their name in the navigation pane.

Could you attach a zipped copy of the database and indicate where to look for the problem?
Best wishes,
Hans

User avatar
Gasman
2StarLounger
Posts: 104
Joined: 22 Feb 2022, 09:04

Re: issue with the referring subform control in sub form criteria

Post by Gasman »

If you are trying to refer to a subform within a subform, I would expect .Form for the first subform as control within a form?

http://access.mvps.org/access/forms/frm0031.htm
Using Access 2007/2019.
Give a man a fish and you feed him for a day. Teach a man to fish and you feed him for a lifetime.
Please, please use code tags when posting code snippets, click the </>icon.
Debug.Print is your lifesaver.

siamandm
BronzeLounger
Posts: 1227
Joined: 01 May 2016, 09:58

Re: issue with the referring subform control in sub form criteria

Post by siamandm »

here its
the criteria is inside the query stdTestMethod, and the main form name is QualityTestReport
Labtests.zip
You do not have the required permissions to view the files attached to this post.

User avatar
Gasman
2StarLounger
Posts: 104
Joined: 22 Feb 2022, 09:04

Re: issue with the referring subform control in sub form criteria

Post by Gasman »

Your first subform control is called tblSamples?
Using Access 2007/2019.
Give a man a fish and you feed him for a day. Teach a man to fish and you feed him for a lifetime.
Please, please use code tags when posting code snippets, click the </>icon.
Debug.Print is your lifesaver.

siamandm
BronzeLounger
Posts: 1227
Joined: 01 May 2016, 09:58

Re: issue with the referring subform control in sub form criteria

Post by siamandm »

i renamed it to frmSamples

User avatar
Gasman
2StarLounger
Posts: 104
Joined: 22 Feb 2022, 09:04

Re: issue with the referring subform control in sub form criteria

Post by Gasman »

Well this produces a value in the immediate window?

Code: Select all

? [Forms]![QualityTestReport].[Form].[tblSamples].[Form].[frmTestResults].[Form].[cboTestNameID]
 1 
However I am getting a prompt for pic attached when trying to open that form?
You do not have the required permissions to view the files attached to this post.
Using Access 2007/2019.
Give a man a fish and you feed him for a day. Teach a man to fish and you feed him for a lifetime.
Please, please use code tags when posting code snippets, click the </>icon.
Debug.Print is your lifesaver.

siamandm
BronzeLounger
Posts: 1227
Joined: 01 May 2016, 09:58

Re: issue with the referring subform control in sub form criteria

Post by siamandm »

yes this is what i get too!

User avatar
Gasman
2StarLounger
Posts: 104
Joined: 22 Feb 2022, 09:04

Re: issue with the referring subform control in sub form criteria

Post by Gasman »

However I cannot find where you are using it? :-(
Using Access 2007/2019.
Give a man a fish and you feed him for a day. Teach a man to fish and you feed him for a lifetime.
Please, please use code tags when posting code snippets, click the </>icon.
Debug.Print is your lifesaver.

User avatar
HansV
Administrator
Posts: 78500
Joined: 16 Jan 2010, 00:14
Status: Microsoft MVP
Location: Wageningen, The Netherlands

Re: issue with the referring subform control in sub form criteria

Post by HansV »

The control name of the first subform is tblSamples even though the name in the navigation pane is frmSamples.
So use
[Forms]![QualityTestReport]![tblSamples]![frmTestResults]![cboTestNameID]

Labtests.zip
You do not have the required permissions to view the files attached to this post.
Best wishes,
Hans

siamandm
BronzeLounger
Posts: 1227
Joined: 01 May 2016, 09:58

Re: issue with the referring subform control in sub form criteria

Post by siamandm »

thank you very much for the support it works now!

siamandm
BronzeLounger
Posts: 1227
Joined: 01 May 2016, 09:58

Re: issue with the referring subform control in sub form criteria

Post by siamandm »

How i requery the second comobox after updating the first one
i tried this didnt work

Code: Select all

Private Sub cboTestNameID_AfterUpdate()

[Forms]![QualityTestReport]![tblSamples]![frmTestResults]![cboTestNameID].Requery


Me.txtMethod.Requery


End Sub

Private Sub Form_Current()

[Forms]![QualityTestReport]![tblSamples]![frmTestResults]![cboTestNameID].Requery
Me.txtMethod.Requery
End Sub

User avatar
HansV
Administrator
Posts: 78500
Joined: 16 Jan 2010, 00:14
Status: Microsoft MVP
Location: Wageningen, The Netherlands

Re: issue with the referring subform control in sub form criteria

Post by HansV »

The version that you attached has

Code: Select all

Private Sub cboTestNameID_AfterUpdate()
    Me.cboMethod.Requery
    Me.txtMethod.Requery
End Sub

Private Sub Form_Current()
    Me.cboMethod.Requery
    Me.txtMethod.Requery
End Sub
That should work.
Best wishes,
Hans

User avatar
Gasman
2StarLounger
Posts: 104
Joined: 22 Feb 2022, 09:04

Re: issue with the referring subform control in sub form criteria

Post by Gasman »

Don't go using full form path if your code is in one of the forms.
I closed the form and tried again and I got the query to work

Code: Select all

SELECT StandardTestMethod.MethodID, StandardTestMethod.MethodDescription, StandardTestMethod.TestNameID
FROM StandardTestMethod
WHERE (((StandardTestMethod.TestNameID)=[Forms]![QualityTestReport].[Form].[tblSamples].[Form].[frmTestResults].[Form].[cboTestNameID]));

Using Access 2007/2019.
Give a man a fish and you feed him for a day. Teach a man to fish and you feed him for a lifetime.
Please, please use code tags when posting code snippets, click the </>icon.
Debug.Print is your lifesaver.