[Last Call] Learn about multicloud storage options and how to improve your company's cloud strategy. Register Now

x
?
Solved

Form and Subforms

Posted on 2011-02-24
4
Medium Priority
?
395 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
[X]
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
  • 2
4 Comments
 
LVL 85

Assisted Solution

by:Scott McDaniel (Microsoft Access MVP - EE MVE )
Scott McDaniel (Microsoft Access MVP - EE MVE ) earned 200 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 1200 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

Free Backup Tool for VMware and Hyper-V

Restore full virtual machine or individual guest files from 19 common file systems directly from the backup file. Schedule VM backups with PowerShell scripts. Set desired time, lean back and let the script to notify you via email upon completion.  

Question has a verified solution.

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

It’s the first day of March, the weather is starting to warm up and the excitement of the upcoming St. Patrick’s Day holiday can be felt throughout the world.
This article describes a method of delivering Word templates for use in merging Access data to Word documents, that requires no computer knowledge on the part of the recipient -- the templates are saved in table fields, and are extracted and install…
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…
Visualize your data even better in Access queries. Given a date and a value, this lesson shows how to compare that value with the previous value, calculate the difference, and display a circle if the value is the same, an up triangle if it increased…

650 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