By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
454,225 Members | 1,434 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 454,225 IT Pros & Developers. It's quick & easy.

Auto-population of fields

P: 6
Hi there. I'm a complete novice trying to create my first database, so please feel free to treat me as such.

I'm trying to track specimens coming through my lab, which will go through several steps of a long procedure. We want to track on what date each step happens for a specimen, and each specimen might go through each step multiple times (if say, a run fails), so I have separate tables for everything: Specimens, Extractions, PCR, Sequencing.

Each of those tables is linked to the next through a key -- each specimen can have multiple extractions, each extraction can have multiple PCRs. In the PCR table, I've built a combo box for people to select the Specimen ID. My question is this: How, after adding a Specimen to the PCR table, do I restrict the Extraction ID column to only those that match the selected Specimen ID? I'd prefer for the Extraction ID field to auto-populate with the latest entry for that Specimen ID selected, if possible.

I hope that's clear. See the picture of the relationships, it might help make more sense. Thanks in advance!

Attached Images
File Type: jpg Relationships.jpg (51.7 KB, 408 views)
Jan 13 '12 #1
Share this Question
Share on Google+
1 Reply

Expert Mod 15k+
P: 31,707
You would use something like the following to populate the ComboBox. The code would run after the [Specimen_ID] control (EG. [txtSpecimen_ID]) had been updated :
Expand|Select|Wrap|Line Numbers
  1. Private Sub txtSpecimen_ID_AfterUpdate()
  2.     Dim strSQL As String
  4.     With Me
  5.         strSQL = "SELECT [Extraction_ID] " & _
  6.                  "FROM   [Exctractions] " & _
  7.                  "WHERE  [Specimen_ID] = " & .txtSpecimen_ID
  8.         .cboExtraction_ID.ControlSource = strSQL
  9.     End With
  10. End Sub
You need to replace the names I've used in the code for those which you've used obviously.
Jan 13 '12 #2

Post your reply

Sign in to post your reply or Sign up for a free account.