Results 1 to 2 of 2
  1. #1
    blinton is offline Novice
    Windows Vista Access 2010 32bit
    Join Date
    Apr 2012
    Posts
    2

    Help with table and relationships design

    Hi I am struggling to add keys and relationships in access to ensure the following:



    Bill is a lab technician
    Jill is a doctor
    doctors perform surgery
    lab technicians perform tests
    Frank is a patient
    Fred is a patient

    I want to record
    Bill performs a test on Frank
    Jill performs surgery on Fred

    but I want to ensure that I can't record
    Bill performs surgery on Fred (because Bill is not a doctor)

    I have made a table of "providers" which includes providername and providertype e.g. Jill,doctor and Bill, Lab Technician
    I have made a table of "providertypes" which includes providertypes e.g. doctor and lab technician
    I have a relationship which means the "providertype" for Jill and Bill must be either doctor or lab technician
    I have a table of "treatmenttypes" which includes treatmenttype and providertype e.g. surgery,doctor and test, lab technician
    I have a table of "patients" which includes patient name e.g. Frank and Fred

    I am creating a table "treatment" which includes patientname, treatmenttype and provider e.g. Fred, Surgery, Jill and Frank, Test, Bill

    but I can't work out how to ensure that I can't enter Fred, Surgery, Bill in that table.

    Any help would be welcome.

    Cheers

  2. #2
    Robeen is offline VIP
    Windows XP Access 2010 32bit
    Join Date
    Mar 2011
    Location
    Tulsa, Oklahoma.
    Posts
    1,596
    If you are using a Form from which to enter data into your Treatment table, then you can put some validation code in the 'Save Record' button to make certain that the mix-ups you mention do not happen.
    The code itself would be pretty simple if you're familiar with using VBA code.
    If not, you can research the DLookup() function to start with and you can see how it can be used to take a value [Eg: ProviderName] from your Form and return a value [Eg: ProviderType] from the Providers table.

    For example, if Bill was being entered to perform Surgery then you might have something like this:
    Code:
    If DLookup("ProviderType" , "Providers" , "ProviderName = 'NameOnForm'") = "Lab Technician" Then
        MsgBox "Lab Technicians do not perform Surgery . . ."
    End If
    This line:
    If DLookup("ProviderType" , "Providers" , "ProviderName = 'NameOnForm'") = "Lab Technician" Then
    is saying:
    If the value in the field "ProviderType" - in the Table "Providers" - where the ProviderName is the NameOnTheForm = "Lab Technician" Then display the Message Box.

    This is just one way to get you started. I know I didn't directly answer about the relationships . . .

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

Similar Threads

  1. Help with Join Relationships in Design View
    By robintmathew in forum Access
    Replies: 8
    Last Post: 02-11-2011, 10:59 AM
  2. Table design and relationships
    By CoachBarker in forum Database Design
    Replies: 1
    Last Post: 10-01-2010, 11:22 AM
  3. Table Relationships
    By goestejs in forum Database Design
    Replies: 3
    Last Post: 08-23-2010, 07:39 AM
  4. Table Relationships
    By seanp in forum Access
    Replies: 2
    Last Post: 04-15-2010, 07:12 AM
  5. Table Design & Relationships
    By mastromb in forum Database Design
    Replies: 16
    Last Post: 12-30-2009, 10:35 PM

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