Solved

Open subform based on current record

Posted on 2012-12-27
2
699 Views
Last Modified: 2012-12-27
Morning Everyone,

Can someone offer some guidance here?

I have a primary form and a subform already created.  I want to place a command button into the detail of the primary form to open a subfrom based on the current record.

I assume I am going to use the Open Form method to accomplish this, however I am having difficulty understanding how to create the WHERE statement.

Both forms are based on primary keys using the same data "Item_Nr".

Form One details "item_Nr" and other information based on header selection

Form two details "Item_Nr" and other information based on a query from numerous tables.

Thanks for any help offered!

MC
0
Comment
Question by:MCaliebe
[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 Comments
 
LVL 61

Accepted Solution

by:
mbizup earned 250 total points
ID: 38724011
By 'subform' do you mean a true subform which is embedded in your main form? or is it a separate popup form?

If it is the latter, you would use code similar to this from Form 1:

Docmd.OpenForm "Form 2", WhereCondition := "Item_Nr = " & Me.[Item_Nr]

Open in new window


That assumes that Item_Nr is numeric.  If it is text, the code would be:

Docmd.OpenForm "Form 2", WhereCondition := "Item_Nr = '" & Me.[Item_Nr] & "'"

Open in new window

0
 

Author Closing Comment

by:MCaliebe
ID: 38724086
It was indeed text.  Thank you for showing the differences.  This goes a long way as simple reference when trying to understand formatting.
0

Featured Post

Free Tool: ZipGrep

ZipGrep is a utility that can list and search zip (.war, .ear, .jar, etc) archives for text patterns, without the need to extract the archive's contents.

One of a set of tools we're offering as a way to say thank you for being a part of the community.

Question has a verified solution.

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

A simple tool to export all objects of two Access files as text and compare it with Meld, a free diff tool.
Phishing attempts can come in all forms, shapes and sizes. No matter how familiar you think you are with them, always remember to take extra precaution when opening an email with attachments or links.
In Microsoft Access, learn the trick to repeating sub-report headings at the top of each page. The problem with sub-reports and headings: Add a dummy group to the sub report using the expression =1: Set the “Repeat Section” property of the dummy…
With Microsoft Access, learn how to start a database in different ways and produce different start-up actions allowing you to use a single database to perform multiple tasks. Specify a start-up form through options: Specify an Autoexec macro: Us…

730 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