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
Solved

Open subform based on current record

Posted on 2012-12-27
2
682 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
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: Postgres Monitoring System

A PHP and Perl based system to collect and display usage statistics from PostgreSQL databases.

One of a set of tools we are providing to everyone as a way of saying 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

Suggested Solutions

This article is a continuation or rather an extension from Cascading Combos (http://www.experts-exchange.com/A_5949.html) and builds on examples developed in detail there. It should be understandable alone, but I recommend reading the previous artic…
Introduction When developing Access applications, often we need to know whether an object exists.  This article presents a quick and reliable routine to determine if an object exists without that object being opened. If you wanted to inspect/ite…
Learn how to number pages in an Access report over each group. Activate two pass printing by referencing the pages property: Add code to the Page Footers OnFormat event to capture the pages as there occur for each group. Use the pages property to …
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…

790 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