Search results

  1. 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...
  2. 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...
  3. 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...
  4. 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...
  5. 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...
  6. 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"
  7. 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...
  8. 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...
  9. 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...
  10. F

    Handling large temporary tables

    I have a database split into a frontend and backend. The front end has several make-table queries that create tables of data on which pivot tables and other analyses queries are based. The make-table queries get re-run every now and then as new data get entered. The resulting tables are huge...
  11. F

    Comparing data across records and returning value

    Hope I'm not wearing out my welcome. Just suddenly facing a lot of tricky queries that are boggling my mind. Any advice or tips much appreciated. I have data on surgeries. A patient goes in and gets one or more metal implants. I also have a flag to indicate his first surgery. If the patient...
  12. F

    Crosstab query with two column headers

    I have data like so, in a junction table between tblPatients and tblComplications: PtID PtCompID Complication CompDate 1 1 CompABC 1/2/05 1 2 CompXYZ 5/2/05 2 3 CompABC 3/2/10 2 4 Comp123 3/2/10 etc.I need it restructured like so...
  13. F

    Associate records based on date values

    I have data like so. This is from a junction table that creates a many-to-many between tblPatients and tblEvents. PtEventID is the PK, PtID is a FK to tblPatients, and EventID is a FK to tblEvents. (I'm showing Event to make it easier to understand.) PtEventID PtID EventID Event...
  14. F

    Crosstab to convert row value into column

    I have a survery database with data stored accordingly: tblSubjects stores info on the subject (e.g., SubjectID, Name) tblQuestions stores into on the questions (e.g., QstnTXT) tblResponses stores info on the responses (e.g., RspnsID, Rspns) I use a query to pull together data from all three...
  15. F

    Find earliest date by group

    I have a junction table that stores patient visits (a patient can have 1 or more visits, and a visit type can be associated with 1 or more patients). For example: PtVisitID PatientID VisitType VisitDate 1 1 Checkup 7/1/10 2 1 Checkup 3/3/10 3...
  16. F

    Transform some rows to columns

    I can use a simple query that shows survey responses like so: SubID QstnBrief Rspns -------------------- 1 Gender Male 1 Color Red 1 Color Blue 1 Color Orange -------------------- 2 Gender Female 2 Color Blue -------------------- etc. Gender = What is you...
  17. F

    Challenge with select query to limit records

    I have a table that tracks changes made to patients' hearing aids (DeviceID) over the course of several doctor visits. In the example below, the patient was given two hearing aids (DeviceID 4 & 5 were "Added") at Visit 1. On Visit 2, DeviceID 5 was repositioned, on Visit 3 it was recalibrated...
  18. F

    table structure to document patient medications

    I'm building a database that needs to document details about patients' medications (name, dose, etc.). The client is interested only in 10 specific medications that he's identified ahead of time. Initially I planned to create a many-to-many between tblPatients and tblMeds, and use a continuous...
  19. F

    Append query with multiple criteria not working

    I have an append query that appends records from Table X to Table Y where Color is Null or <> "Red": WHERE (((tblColors.Color)<>"Red" Or (tblColors.Color) Is Null));This works fine. But when I try to add a third condition, like <> "Orange", it seems to ignore the <>Red and <>Orange criteria...
  20. F

    Parse open args into three strings

    I have an open args statement with three values, separated by pipes ("|"). In the on load event of a form, I need to parse out the three values as strings. The following works if there are just two arg values. How can I change it so it works with three? Dim intPos As Integer Dim...
Top Bottom