Make It Impossible to Enter Record With Information Missing

JPed

Registered User.
Local time
Today, 06:34
Joined
Feb 11, 2014
Messages
29
Hi,

I have a form and was wondering if it was possible to set it so that a user is not able to click the submit [Submitcmd] unless certain text boxes are filled (however SampleOuttxt needs to be able to remain blank).

Any help would be appreciated

J
 
You can use the Before Update of the Form. http://www.baldyweb.com/BeforeUpdate.htm
Do you know how it would be possible to write it so it has the same effect for multiple option boxes? I tried copying out the code twice but I receive an error message

"The macro or function set to the BeforeUpdate or ValidationRule property for this field is preventing Microsoft Access from saving the data in the field"

Would preferably want it to look to see if any of SomeControl1, SomeControl2, etc are empty and reply saying to fill in all required fields
 
JPed,

I have handled this issue in a couple of ways.
1) Make the Submit button invisible until data exist in all the required fields. This requires more programming, but may be necessary for some customers.
2) When the Submit button is clicked, go through a check of each required field and if anything is missing, show a warning message. Here is the beginning of one of my Submit buttons:
Code:
 Private Sub btnSubmit_Click()
    Dim intResponse As Integer
    Dim numNewRec As Double
    Dim strSQL As String
    Dim dtRcd As Date
    Dim db As Database
    Dim rs As DAO.Recordset
 
' = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = =
' Validation checks
' = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = =
    ' Check that required fields are filled in.
   If (IsNull(dtReceived) = True) _
      Or (IsNull(cboType) = True) _
      Or (IsNull(cboSource) = True Or Len(cboSource) = 0) _
      Or (IsNull(txtCLast) = True Or Len(txtCLast) = 0) _
   Then
      intResponse = MsgBox("REQUIRED Fields are:" & vbCrLf _
      & "    Date Received," & vbCrLf _
      & "    Client Type," & vbCrLf _
      & "    Client Source, and" & vbCrLf _
      & "    Client Last Name.", vbExclamation, "Validation Failed")
      cboType.SetFocus
   Else...
      ...
      ...
   End If
End Sub
I think you can see how that works. If any of the 4 required fields aren't filled in, then the subprocedure ends there. Otherwise, the rest of the code plays out.

HTH
:cool:
 

Users who are viewing this thread

Back
Top Bottom