Search results

  1. F

    Find date in Table 1 closest to another date in Table 2

    Plog - That worked perfect. Thanks much!
  2. F

    Find date in Table 1 closest to another date in Table 2

    I have a table, tblVisits, holding patient's pre and post surgery visits: PatientID VisitDate 1 1/5/12 1 3/10/12 1 9/1/13 2 ...And another table holding patient's surgeries (each patient will have only one surgery) PatientID SurgeryDate 1 4/1/12 2 ... I need...
  3. F

    Extract one record per unique ID

    Got it! Use a total query with Group By for PatientID, Min for VisitDate, First for any other variables needed, like Complaint, and Where for TestPos. SELECT TestTable.PatientID, Min(TestTable.VisitDate) AS MinOfVisitDate, First(TestTable.Complaint) AS FirstOfComplaint FROM TestTable WHERE...
  4. F

    Extract one record per unique ID

    I have a table like so: PatientID VisitDate Complaint TestPos 1 4/5/2003 Coughing 1 1 1/2/2007 Sneezing 1 5/1/2008 Unknown 1 2 2/1/1988 Unknown 2 4/2/1988 Unknown 1I'd like to extract just one TestPos record (TestPos = 1) per...
  5. F

    Crosstab to convert rows to columns

    I have data like: SubjectID VisitID VisitNum VisitDate VisitDetail Rspns 1 5 1 2/10/2001 Fever_1 Yes 1 5 1 2/10/2001 Age_1 12 2 7 1 5/08/2010 Fever_1 No 2 7 1 5/08/2010 Age_1 18 2...
  6. F

    Running count within group

    Thank you. This did the trick.
  7. F

    Running count within group

    Hmm ... each row has several variables that make each row unique. I left them out just to save space. It's typical normalized data, so something like: SubjectID VisitID Question Response 1 5 Fever Yes 1 5 Age 12 2 7 Fever No 2...
  8. F

    Running count within group

    I have data like so: SubjectID VisitID 1 5 1 5 2 7 2 7 2 9 2 9 etcAnd need to return a running count for the number of visits per subject, so: SubjectID VisitID VisitCount 1 5 1 1 5 1 2 7 1 2 7 1 2 9 2 2 9 2 etc.I'd like to use DCount and...
  9. F

    Pass table names to delete query

    I realize the table structure departs from normal form, but these are temporary tables that are created through a bunch of routines designed to create separate tables for use in statistical software. A dynamic query in VBA is exactly what I'm trying to figure out. Below is the very rusty code...
  10. F

    Pass table names to delete query

    I use the following code to delete from a table all records except those meeting the WHERE criteria: DELETE tblABC.*, tblABC.SubjectID FROM tblABC WHERE (((tblABC.SubjectID)<>99 And (tblABC.SubjectID)<>432));I'd like to run this exact same query, but on many other tables, all of which are...
  11. F

    SQl statement with two where conditions

    That was it! Thank you.
  12. F

    SQl statement with two where conditions

    For the life of me I cannot get the correct syntax for this. The punctuation for the second where condition is incorrect. Any suggestions? Me.cboDose.RowSource = "SELECT Label FROM tblLookup WHERE tblLookup.[Med]='" & Me.cboMed & "'" AND tblLookup.[Notes] = "Swallowed"
  13. F

    Medication data - complex grid

    And as for the underlying table structure, four separate tables - one for each type of medication? For example: tblSwallowed -------------- MedicationID MedicationName Dose DoseOther tblOral -------------- MedicationID MedicationName Dose DoseDuration WhenPrescribed WhatIsItFor etc.
  14. F

    Medication data - complex grid

    I need to create a database that collects, among other things, medications (with dose information) for patients. Attached is a screenshot of the form currently being used to collect the medication data. The client would like the database interface to reflect the form layout as much as...
  15. F

    Query to crosstabulate data

    I asked 18 people to each sort 100 statements into piles based on the similarity of the statements. The results are arranged as below. For example: - Bob sorted statements 1, 3, and 100 into the same pile (Pile ID = 5), and statements 2 and 4 into the same pile (Pile ID = 2). - Mary sorted...
  16. F

    Delete query - delete records based on criteria in another table

    lagbolt: Thanks to you suggestion I got it working. This is the final query that does the trick: DELETE tblPeopleStates.PersonID, tblPeopleStates.StateID FROM tblPeopleStates WHERE (((tblPeopleStates.PersonID)=[Forms]![frmMain]![subform1].[Form]![subform2].[Form]![PersonID]) AND...
  17. F

    Delete query - delete records based on criteria in another table

    Not everyone will have a region assignment. Some people just have states assigned to them. Hence the need to sometimes treat them as separate constructs.
  18. F

    Delete query - delete records based on criteria in another table

    Attached is a paired down version of my database, showing the key pieces. The form that opens has some instructional text to show what I'm trying to do. There are many ways to tackle this, and I thought that referencing a stored delete query would be the most straightforward. Essentially...
  19. F

    Delete query - delete records based on criteria in another table

    I am trying to create a delete query that, for a given person, deletes records in Table B that do not have a corresponding record in Table A. Here are the relevant tables: tblStates holds StateID, StateName, and RegionID (RegionID is a FK to tblRegions). tblPeopleStates is a junction table...
  20. F

    Handling large temporary tables

    Solely for performance reasons. The queries that make the table include several calculated variables and sub-queries that make the query very slow, especially when I'm dealing with thousands of records. Consequently, any filtering done on the query (e.g., via pivot table) takes forever to process.
Top Bottom