How to carry over values from a many-to-many table for use in a new record

TonyD1016

Board Regular
Joined
Nov 18, 2021
Messages
59
Office Version
  1. 365
Platform
  1. Windows
I'm currently working on a database that stores information related to court orders.

My current setup is a table (tblDocketInfo) that contains an individual records of the court orders each time one comes in, including the ID autonumber, the Docket Number, the Letter Date, as well a 5-digit case number that is the foreign key to a client table, a foreign key for the judge table, and other pertinant info.

Since each client can have more than one attorney assigned to them, I have a lookup table that relates the AttorneyID autonumber on the table of attorneys to the RecordID of tblDocketInfo. This information for the attorney's assigned to each case is displayed in Datasheet view in a subform of the form which displays the docket info.

On this same form, the Docket Number field is a combo box that uses a query to retrieve each retrieves all unique existing docket number for the given Client case# and allows the user to select one. If they do, the following VBA code is applied to several fields on the form:

VBA Code:
If Me.NewRecord Then
        txtLastCourtDate.Value = DLookup("[LastCourtDate]", "[qlkpDocketFill]")
        txtReportSubmitDate.Value = DLookup("[ReportSubmitDate]", "[qlkpDocketFill]")
        cboCounty.Value = DLookup("[CountyID]", "[qlkpDocketFill]")
        cboJudge.Requery
        cboJudge.Value = DLookup("[JudgeID]", "[qlkpDocketFill]")
        txtNotes.Value = DLookup("[CourtUpdates]", "[qlkpDocketFill]")
End If

The lookup query DocketFill does the following:
SQL:
SELECT TOP 1 tblDocketInfo.RecordID, tblDocketInfo.DocketNumber, tblDocketInfo.[Case#], tblDocketInfo.LetterDate, tblDocketInfo.CommitID, tblDocketInfo.CommitDate, tblDocketInfo.LengthID, tblDocketInfo.LastCourtDate, tblDocketInfo.ReportSubmitDate, tblDocketInfo.NextCourtDate, tblDocketInfo.CountyID, tblDocketInfo.JudgeID, tblDocketInfo.CourtUpdates
FROM tblDocketInfo
WHERE (((tblDocketInfo.RecordID) In (SELECT TOP 1 RecordID
FROM tblDocketInfo AS Dupe
Where Dupe.DocketNumber = [Forms]![frmDocketInfo]![cmbDocket]
ORDER BY Dupe.RecordID DESC)))
ORDER BY tblDocketInfo.RecordID;

This checks the most recent entry on the DocketInfo table and carries over any existing values from the most recent previous Court order for use in the new record.

I would like to also carry over any existing attorney's that are assigned to that previously existing record and have them be displayed in the subform (or added to the .
What would be the best way to accomplish this?
 

Excel Facts

Quick Sum
Select a range of cells. The total appears in bottom right of Excel screen. Right-click total to add Max, Min, Count, Average.

Forum statistics

Threads
1,223,886
Messages
6,175,190
Members
452,616
Latest member
intern444

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top