Solved

Form and Subforms

Posted on 2011-02-24
4
346 Views
Last Modified: 2012-05-11

I have a form with two subforms:
Subform A= a query that matches expense records from Quickbooks to a more general category.  This is a datasheet form
Subform B= a form on the original table for the expense records; this is a regular form, one record at a time

I have two separate ones because I want the users to see the general category name, but also to be able to edit the records in the original table (I've added a field where they an assign an account)

My question is:
Once I've got the two subforms on a form, how do I link them so that scrolling through the datasheet pulls up the same record on the other subform, where they can add notes and assign an account?  They share the field "txnlineID"
0
Comment
Question by:BBlu
  • 2
4 Comments
 
LVL 84

Assisted Solution

by:Scott McDaniel (Microsoft Access MVP - EE MVE )
Scott McDaniel (Microsoft Access MVP - EE MVE ) earned 50 total points
ID: 34976654
You can do something like this in the "first" subform:

Dim rst As DAO.Recordset

Set rst = Me.Parent.NameOfYourSecondSubformCONTROL.Form.RecordsetClone

rst.FindFirst "txnLineID='" & Me.txnLineID & "'"
If Not rst.NoMatch Then Me.Parent.NameOfYourSecondSubformCONTROL.Form.Bookmark = rst.Bookmark

This would be done in the Current event of your first subform.

I seem to recall being able to do something like this use an unbound Textbox on the Mainform, and setting the value of that Textbox in the first subform. Seems that you used that Textbox as one of the Link fields for the second subform (or may have been the ONLY link field, can't recall), but I'm just not sure.
0
 

Author Comment

by:BBlu
ID: 34983028
I'm getting an error: Run-time error '2465';
Application-defined or object-defined error

It stops on the:
Set rst = Me.Parent.NameOfYourSecondSubformCONTROL.Form.RecordsetClone
line (see attached) error line
0
 

Author Comment

by:BBlu
ID: 35072185
Is anyone available to help with this problem?
0
 
LVL 21

Accepted Solution

by:
Boyd (HiTechCoach) Trimmell, Microsoft Access MVP earned 300 total points
ID: 35152633
It sounds like what you need is what I call cascading sub forms.

The simplest method I know uses no VBA code. That's right no code.  Place a hidden text box on the main/parent form that has a control source that references a control on the first sub form that has the primary key value used to identify the record to show in the second sub form. The second sub form uses the text box as the master linking field.
0

Featured Post

Complete VMware vSphere® ESX(i) & Hyper-V Backup

Capture your entire system, including the host, with patented disk imaging integrated with VMware VADP / Microsoft VSS and RCT. RTOs is as low as 15 seconds with Acronis Active Restore™. You can enjoy unlimited P2V/V2V migrations from any source (even from a different hypervisor)

Question has a verified solution.

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

Suggested Solutions

I originally created this report in Crystal Reports 2008 where there is an option to underlay sections. I initially came across the problem in Access Reports where I was unable to run my border lines down through the entire page as I was using the P…
Overview: This article:       (a) explains one principle method to cross-reference invoice items in Quickbooks®       (b) explores the reasons one might need to cross-reference invoice items       (c) provides a sample process for creating a M…
Get people started with the utilization of class modules. Class modules can be a powerful tool in Microsoft Access. They allow you to create self-contained objects that encapsulate functionality. They can easily hide the complexity of a process from…
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…

919 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

14 Experts available now in Live!

Get 1:1 Help Now