Solved

Open subform based on current record

Posted on 2012-12-27
2
648 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

How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

Join & Write a Comment

When you are entering numbers in a speadsheet, and don't remember what 6×7 is, you just type “=6*7" instead. It works in every cell! This is not so in Access. To enter the elusive 42 in a text box, you have to find a calculator, and then copy the re…
Introduction The Visual Basic for Applications (VBA) language is at the heart of every application that you write. It is your key to taking Access beyond the world of wizards into a world where anything is possible. This article introduces you to…
In Microsoft Access, learn how to “cascade” or have the displayed data of one combo control depend upon what’s entered in another. Base the dependent combo on a query for its row source: Add a reference to the first combo on the form as criteria i…
Using Microsoft Access, learn some simple rules for how to construct tables in a relational database. Split up all multi-value fields into single values: Split up fields that belong to other things into separate tables: Make sure that all record…

705 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

Need Help in Real-Time?

Connect with top rated Experts

20 Experts available now in Live!

Get 1:1 Help Now