Solved

Form and Subforms

Posted on 2011-02-24
4
356 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

Comprehensive Backup Solutions for Microsoft

Acronis protects the complete Microsoft technology stack: Windows Server, Windows PC, laptop and Surface data; Microsoft business applications; Microsoft Hyper-V; Azure VMs; Microsoft Windows Server 2016; Microsoft Exchange 2016 and SQL Server 2016.

Question has a verified solution.

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

Suggested Solutions

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…
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…
Show developers how to use a criteria form to limit the data that appears on an Access report. It is a common requirement that users can specify the criteria for a report at runtime. The easiest way to accomplish this is using a criteria form that a…
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…

770 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