Results 1 to 9 of 9
  1. #1
    Vilius01 is offline Novice
    Windows 7 32bit Access 2007
    Join Date
    Jun 2014
    Posts
    4

    Access 2007 query to combine records from two different tables

    Hi all



    I am a novice access user and have been working on this access 2007 patient database that should ease the track of health records and generate invitation letters to perform specific tests. I have a selection query that filters patients I need to invite and a table with stored available visit times. I need to to create a query that links patients to defined number of free visit times e.g. for the upcoming month or so, one patient per one time record. Any ideas how to do that? Thank in advance.

  2. #2
    ItsMe's Avatar
    ItsMe is offline Sometimes Helpful
    Windows 7 64bit Access 2010 32bit
    Join Date
    Aug 2013
    Posts
    7,862
    What is the rule for free visits?

  3. #3
    June7's Avatar
    June7 is online now VIP
    Windows 7 64bit Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    52,931
    As ItsMe asks, what rule(s) should Access follow in associating patient with free visit time slot? What decision process would you use if you manually selected time slot for each patient (this is an option)? To automate a batch assignment, I suspect these rules cannot be built into query and this will require VBA code.
    How to attach file: http://www.accessforums.net/showthread.php?t=70301 To provide db: copy, remove confidential data, run compact & repair, zip w/Windows Compression.

  4. #4
    Vilius01 is offline Novice
    Windows 7 32bit Access 2007
    Join Date
    Jun 2014
    Posts
    4
    Thanks for your replies, well patients will have an opportunity to change their visit time later on, when they'll receive invitation letter, so probably the time can be assigned in the order as patients are sorted in the selection query i.e. patient in the top row is given the earliest time and so on. Despite that there are no other rules.

  5. #5
    June7's Avatar
    June7 is online now VIP
    Windows 7 64bit Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    52,931
    Just reinforces my assessment that this will require VBA code. The code would open recordset objects of Patients and VisitTimes tables with appropriate filtering, then loop through the recordsets and insert records in Appointments table.
    How to attach file: http://www.accessforums.net/showthread.php?t=70301 To provide db: copy, remove confidential data, run compact & repair, zip w/Windows Compression.

  6. #6
    Vilius01 is offline Novice
    Windows 7 32bit Access 2007
    Join Date
    Jun 2014
    Posts
    4
    Would anyone help me with the code since VBA is smth I am completely unfamiliar.

  7. #7
    June7's Avatar
    June7 is online now VIP
    Windows 7 64bit Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    52,931
    This sounds like significant effort and know nothing about your db structure.

    Suggest you need to become familiar with coding. Start with:

    http://office.microsoft.com/en-us/ac...010341717.aspx

    http://chandoo.org/wp/2011/05/13/int...o-programming/

    http://allenbrowne.com/ser-29.html
    How to attach file: http://www.accessforums.net/showthread.php?t=70301 To provide db: copy, remove confidential data, run compact & repair, zip w/Windows Compression.

  8. #8
    ItsMe's Avatar
    ItsMe is offline Sometimes Helpful
    Windows 7 64bit Access 2010 32bit
    Join Date
    Aug 2013
    Posts
    7,862
    I would add that you need to understand the RDBMS side of things before you can start coding. Perhaps you can start by learning RDBMS fundamentals so you can create the correct table structure.

  9. #9
    Vilius01 is offline Novice
    Windows 7 32bit Access 2007
    Join Date
    Jun 2014
    Posts
    4
    Sorted without vba, two additional empty tables were needed with all necessary fields i.e time in the first and patients in the second, plus auto-number ID field in both tables, than you make two append queries one for patients, the other for time. When you append records to empty tables autonumber assigns each entry with number which is your linked field in selection query to select patients and time in one record set. Afterwards you can make delete query to erase data in additional tables. You put everything in macro and works just fine, except the fact that autonumber does not reset its count, for that you need to restart database and compact it on close.

Please reply to this thread with any new information or opinions.

Similar Threads

  1. Replies: 1
    Last Post: 11-29-2013, 05:18 PM
  2. Replies: 1
    Last Post: 05-08-2013, 07:08 PM
  3. Switch function query to combine tables
    By sandlucky in forum Queries
    Replies: 2
    Last Post: 03-29-2011, 09:46 PM
  4. I have 4 Tables in Access - can I combine them?
    By officespace in forum Access
    Replies: 6
    Last Post: 02-22-2009, 07:21 AM
  5. combine three tables in a query
    By neuenglander in forum Queries
    Replies: 0
    Last Post: 08-21-2008, 04:02 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Other Forums: Microsoft Office Forums