Results 1 to 4 of 4
  1. #1
    John V is offline Advanced Beginner
    Windows 7 32bit Access 2010 32bit
    Join Date
    Jan 2014
    Posts
    43

    Ensure that all required fields are filled in before closing form

    My Database is coming along nicely, thanks to the people here.

    I have come to the next issue in designing my form, however.

    The process is this, the user creates a Patient in the database using the Contact Information Form and then they can fill out a form for the Doctors Visit using the Patient Encounter Form. On the Patient Encounter form they have to select the Patient ID Number so the database knows which patient the form is for.

    The Patient Encounter Form is made up of 14 subforms for everything from "Type of Encounter" and "Encounter Date" to "Dietician" and "Referrals". The Record Source for the Main form of the Patient Encounter Form is the Contact Information Table. The Combo Box for choosing the Patient ID Number is unbound, with a Record Source that gets the list from the Patient ID Field in the Contact Information Table (PK).

    There is a "New" button that clears the fields on all of the subforms and starts a new record on each of the underlying tables. It does not clear the Patient ID choice in the Patient ID Combo Box.

    The user can move away from the current record by doing one of three things:
    A) Press the "New" button
    B) Choose a different Patient ID in the Combo Box


    C) Close the form

    There are fields is the form that are required. These are Patient ID, Encounter Date, Type of Encounter, and they must make at least one choice in at least one of the other areas of the form (i.e. Targeted Care/CDM, Dietician, Referrals) I have already set the Type of Encounter and Encounter Date to required in the under lying tables. No other fields are set to required in the underlying tables.

    I want to check that the requirements for filling in the form have been met before the user moves away from the current record by one of the choices above. How do I do this?

    I have attached a copy of my database thus far. I have already created 4 Patients using the Contact Information Form. So please focus on the Patient Encounter Form.

    Thank you
    John V

    Wetaskiwin.zip

  2. #2
    June7's Avatar
    June7 is offline VIP
    Windows 7 64bit Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    53,625
    Options:

    1. set the fields as required in the table and let Access nag the users when they try to leave form without entering data

    3. code in the form BeforeUpdate event checks if data in required fields and acts appropriately
    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.

  3. #3
    John V is offline Advanced Beginner
    Windows 7 32bit Access 2010 32bit
    Join Date
    Jan 2014
    Posts
    43
    Quote Originally Posted by June7 View Post
    Options:

    1. set the fields as required in the table and let Access nag the users when they try to leave form without entering data

    3. code in the form BeforeUpdate event checks if data in required fields and acts appropriately
    I have tried option 1 and it doesn't work. Also I cant do that for about half of the subforms (and their underlying tables) because not every field is required the user just has to pick at least one of the choices on at least one of the subforms (Tables), but not all of them.

    Not sure what the code would be for the other option (I am very new to this) but I will do some research and maybe be back with more questions.

    John V

  4. #4
    June7's Avatar
    June7 is offline VIP
    Windows 7 64bit Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    53,625
    The phrase 'user just has to pick at least one of the choices' makes me think the data structure is not normalized. Are these a bunch of Yes/No fields?

    The code would be like:

    Sub Form_BeforeUpdate(Cancel As Integer)
    If Me.checkbox1=0 And Me.checkbox2=0 Then
    MsgBox "Must select one option."
    Cancel = True
    End If
    End Sub
    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.

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

Similar Threads

  1. Replies: 8
    Last Post: 08-02-2012, 02:53 PM
  2. How do I see only fields that are filled?
    By fabiobarreto10 in forum Forms
    Replies: 56
    Last Post: 01-01-2012, 09:51 PM
  3. Replies: 5
    Last Post: 12-06-2011, 05:21 AM
  4. Required Fields in a Form
    By Alaska1 in forum Access
    Replies: 3
    Last Post: 12-23-2010, 01:41 PM
  5. Replies: 2
    Last Post: 03-14-2010, 08:21 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