Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Reference subform control from query problem 2

Status
Not open for further replies.

Primomikey

Technical User
Aug 25, 2011
3
GB
Hi all.
I am trying to reference a subform control from a Query but am encountering a persistent error which suggests bad referencing on my part but I am at a loss to pinpoint.

Main form is frmCreateRFS
Subform is frmRFSHardwareSubForm
Controls EventType & DSTItemID

The intention is to select a value for EventType on the subform.
Then (on subform as well) click on combo DSTItemID which is sourced through a query to filter the results of the combo.

When trying this with just the subform, it works fine. but when tried with the subform in the mainform, the query asks me to enter a parameter value. I have tried variations of the following reference in the query:

[Forms]![frmCreateRFS]![frmRFSHardwareSubform].[Form].[EventType]

Any help would be appreciated.
Many thanks.
 
try

[Forms]![frmCreateRFS].form![frmRFSHardwareSubform].[Form]
![EventType]
 
Thanks for the reply seaport.

Tried this and got the same response.
The 'Enter Parameter Value' dialog box shows part of the reference statement with the usual input, OK and Cancel options. If I manually enter the value into this the query will then work.

Tested the subform on it's own again this morning and it worked with

[Forms]![frmRFSHardwaresubform]![EventType]

Checked name of mainform and confirmed as frmCreateRFS


 
Possible two reasons:
1. the form name or the control name is wrong.
2. EventType might be a reserved word. Try rename it as txtEventType.
 
Primomikey,
Do you understand that the name of the subform control on the main form may not be the same as the name of the source object. I expect your source object is frmRFSHardwareSubform but the subform control name might be something else.

Duane
Hook'D on Access
MS Access MVP
 
How are ya Primomikey . . .

Agree with [blue]dhookom[/blue].
[ol][li]Open the [blue]MainForm[/blue] in design view.[/li]
[li]Call up the properties window and select the [blue]Other[/blue] tab.[/li]
[li]Click the outline of the subform to select it.[/li]
[li]What do you show in the [blue]Name[/blue] property of the properties window?[/li][/ol]
[blue]Your Thoughts? . . .[/blue]

See Ya! . . . . . .

Be sure to see faq219-2884 [blue]Worthy Reading![/blue] [thumbsup2]
Also faq181-2886 [blue]Worthy Reading![/blue] [thumbsup2]
 
Many thanks dhookom and TheAceMan1 for replying.

Your pointers were spot on as I was incorrectly referencing the subform within the mainform. Works fine now. Many thanks to all for your help.

Brgds.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top