Results 1 to 6 of 6
  1. #1
    woodpecker is offline Novice
    Windows 8 Access 2013 64bit
    Join Date
    Oct 2017
    Posts
    11

    close form button with additional criteria

    I have a form that after it is opened the fields are required to be filled in.
    when they click the close button I want to make sure they have filled in the fields, if they click the close button before they start filling in the form it will close. Once the form is open I want it so the form cannot be close no matter what, until all the fields are filled in.
    I am a beginner so I have limited VBA code skills.

    I was thinking of either a select or IF statement

    If Fname field null then
    cmd.open.frmMailingList
    else


    close form

    Help Please

  2. #2
    June7's Avatar
    June7 is online now VIP
    Windows 10 Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    52,898
    Do you mean the X Close? I would disable the X Close and use a Command Button control.

    Code like:
    Code:
    Private Sub Command68_Click()
    If Not Me.Dirty Then
        Cancel = True
        MsgBox "Enter data"
    Else
        If IsNull(Me.Rate) Or IsNull(Me.RateID) Then
            MsgBox "Still missing data."
        Else
            DoCmd.Close
        End If
    End If
    End Sub
    How does record even get created without data if data is required?
    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
    woodpecker is offline Novice
    Windows 8 Access 2013 64bit
    Join Date
    Oct 2017
    Posts
    11
    I disable the X this is the close command button.

    This organization helps people with mental health issues and when people call and want to be added tot he mailing list we create a report run monthly of people to be added to the list. The employees are not diligent in recording people's information when filling out their daily log form, when they click the button that the person want to be added to the mailing list it opens the mailing list form. so I have created it so they have to record the info and not close the forms. The daily log reports show how the employees do not enter the info.

    I will try the code you have supplied thank you

  4. #4
    woodpecker is offline Novice
    Windows 8 Access 2013 64bit
    Join Date
    Oct 2017
    Posts
    11
    Quote Originally Posted by June7 View Post
    Do you mean the X Close? I would disable the X Close and use a Command Button control.

    Code like:
    Code:
    Private Sub Command68_Click()
    If Not Me.Dirty Then
        Cancel = True
        MsgBox "Enter data"
    Else
        If IsNull(Me.Rate) Or IsNull(Me.RateID) Then
            MsgBox "Still missing data."
        Else
            DoCmd.Close
        End If
    End If
    End Sub
    How does record even get created without data if data is required?
    This is the table fields for the form. should I be using the name of one of these fields because it does not like (Me.Rate) The name of the form is frmMailingList
    Click image for larger version. 

Name:	UntitledMailing List Table.jpg 
Views:	10 
Size:	35.3 KB 
ID:	30901

  5. #5
    June7's Avatar
    June7 is online now VIP
    Windows 10 Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    52,898
    I gave you example code. Use your object names where appropriate. Which fields are required - all of them?
    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
    woodpecker is offline Novice
    Windows 8 Access 2013 64bit
    Join Date
    Oct 2017
    Posts
    11
    Yes I figured that out and it works great thank you

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

Similar Threads

  1. HELP with close form button
    By acampbell in forum Macros
    Replies: 4
    Last Post: 01-20-2017, 09:34 AM
  2. If number then set close button on form to false
    By Ruegen in forum Programming
    Replies: 6
    Last Post: 10-20-2013, 09:09 PM
  3. Close Form button not working
    By RedGoneWILD in forum Forms
    Replies: 2
    Last Post: 06-25-2012, 07:02 AM
  4. Disable master form close button
    By Carpy01 in forum Forms
    Replies: 3
    Last Post: 12-31-2010, 05:41 PM
  5. Replies: 4
    Last Post: 09-10-2009, 03:09 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