Solved

Form and Subforms

Posted on 2011-02-24
4
336 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
Comment Utility
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
Comment Utility
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
Comment Utility
Is anyone available to help with this problem?
0
 
LVL 21

Accepted Solution

by:
Boyd (HiTechCoach) Trimmell, Microsoft Access MVP earned 300 total points
Comment Utility
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

Threat Intelligence Starter Resources

Integrating threat intelligence can be challenging, and not all companies are ready. These resources can help you build awareness and prepare for defense.

Join & Write a Comment

QuickBooks® has a great invoice interface that we were happy with for a while but that changed in 2001 through no fault of Intuit®. Our industry's unit names are dictated by RUS: the Rural Utilities Services division of USDA. Contracts contain un…
A simple tool to export all objects of two Access files as text and compare it with Meld, a free diff tool.
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…
Access reports are powerful and flexible. Learn how to create a query and then a grouped report using the wizard. Modify the report design after the wizard is done to make it look better. There will be another video to explain how to put the final p…

772 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

11 Experts available now in Live!

Get 1:1 Help Now