Solved

Referencing a field on a subform

Posted on 2011-03-16
4
258 Views
Last Modified: 2012-05-11
See attached.

I have a header form (frmPackHeader) and a subform (frmPackDetail).
(One to many relationship)

On the header there is a button that activates the code below.
In particular note

WHERE (((tblPackDetail.PackDetailID)=[forms]![frmPackDetail]![PackDetailID]));

When I click on the button I am prompted to enter [forms]![frmPackDetail]![PackDetailID].  WHY ?
Surely the [forms]![frmPackDetail]![PackDetailID] field already has a value??  Why do I need to input it?


I hope the above is clear ...?
Private Sub Command7_Click()
DoCmd.OpenQuery "query1"
End Sub

Open in new window

Database7.accdb
0
Comment
Question by:Patrick O'Dea
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
4 Comments
 
LVL 75

Accepted Solution

by:
DatabaseMX (Joe Anderson - Microsoft MVP, Access and Data Platform) earned 500 total points
ID: 35152572
Change your query criteria to:

[forms]![frmPackHeader]![frmPackDetail].[Form].[PackDetailID]

mx
0
 
LVL 75
ID: 35152588
OR   [forms]![frmPackHeader]![PackDetailID]

depending on where you are trying to get the ID from ... Main for or Sub form (this would be Main form - first post is for SubForm)

mx
0
 
LVL 120

Expert Comment

by:Rey Obrero (Capricorn1)
ID: 35152589
try this


WHERE (((tblPackDetail.PackDetailID)=[forms]![frmPackHeader]![frmPackDetail].[form]![PackDetailID]));
0
 

Author Closing Comment

by:Patrick O'Dea
ID: 35152597
Perfect.  Nice and easy!
0

Featured Post

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

I see at least one EE question a week that pertains to using temporary tables in MS Access.  But surprisingly, I was unable to find a single article devoted solely to this topic. I don’t intend to describe all of the uses of temporary tables in t…
Access custom database properties are useful for storing miscellaneous bits of information in a format that persists through database closing and reopening.  This article shows how to create and use them.
Familiarize people with the process of retrieving data from SQL Server using an Access pass-thru query. Microsoft Access is a very powerful client/server development tool. One of the ways that you can retrieve data from a SQL Server is by using a pa…
In Microsoft Access, learn how to use Dlookup and other domain aggregate functions and one method of specifying a string value within a string. Specify the first argument, which is the expression to be returned: Specify the second argument, which …

733 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question