Results 1 to 2 of 2
  1. #1
    banpreet is offline Competent Performer
    Windows 8 Access 2010 64bit
    Join Date
    Jul 2016
    Posts
    117

    Prevent user from submitting form until record has been filled out in subform

    Hi guys,



    I have a form that needs certain fields to be filled out before being submitted to manager to approve. The problem is the submit button is on the the form and I can make all the fields required on the form to be filled out before being submitted. The problem is that I have a subform which is a table that needs atleast one record filled out before being submitted. But the main button to submit the form is on the main form and not on the subform. So I can't make the fields on the subform required on the main form because there is no association. Somebody mentioned that I should create a field in my main form that counts how many records has been entered on the subform, so it starts off at 0 then 1, and so on, and they could submit the form until the field is at 1. How do I do this? or does anybody have any better way.

  2. #2
    ranman256's Avatar
    ranman256 is online now VIP
    Windows Vista Access 2010 32bit
    Join Date
    Apr 2014
    Location
    Kentucky
    Posts
    9,525
    on the Submit button, have the code check all fields, then allow or prevent:
    Code:
    sub btnSubmit_click()
    If IsValidForm() Then
            'post changes
       SaveData
       DoCmd.Close
    End If
    
    Private Function IsValidForm() As Boolean
    Dim vMsg
    Select Case True
       Case IsNull(forms!subform!form!dtpWeekOf)
          vMsg = "Date field missing"
       Case IsNull(forms!subform!form!cboUser)
          vMsg = "Teacher name is missing"
       Case IsNull(forms!subform!form!cboSubj)
          vMsg = "Subject field is missing"
    End Select
    If vMsg <> "" Then MsgBox vMsg, vbCritical, "Required Field"
    IsValidForm = vMsg = ""
    End Function

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

Similar Threads

  1. Replies: 3
    Last Post: 04-15-2017, 11:13 AM
  2. Replies: 6
    Last Post: 04-23-2016, 04:10 PM
  3. Prevent user adding duplicate data in form
    By littlejnz in forum Forms
    Replies: 1
    Last Post: 06-30-2014, 08:28 AM
  4. Replies: 3
    Last Post: 01-05-2012, 09:57 AM
  5. Replies: 2
    Last Post: 12-07-2011, 02:51 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