Results 1 to 3 of 3

Thread: Empty Fields

  1. #1
    Join Date
    Aug 2013

    Unanswered: Empty Fields

    I have a "Work Order" form with many fields to be filled out by our technicians. I want to ensure that when they finish there are no blank fields left. Is there a way when the "Finished Date" field is entered that all of the required fields are filled out? I don't want this to happen until the "Finished Date" field is completed so the "Work Order" can be opened and have some of the fields filled out during the process of work being accomplished.

    Thanks in advance!

  2. #2
    Join Date
    Nov 2004
    out on a limb
    Provided Answers: 59
    put some validation code behind the forms BEFORE UPDATE event
    if the validations fail then set the cancel variable/parameter = true

    if mycontrol.value >50 then
    cancel= true
    strmessage = "Mycontrol value (" & mycontrol.value & ") is out of range must be below 50"
    if mydatecontrol > date() then
    cancel= true
    strmessage = strmessage & vbcrlf & "mydatecontrol value "(& format(mydatecontrol,"dd mmm yyyy") & ")" is greater than todays date"

    msgbox strmessage, "Data errors detected"
    I'd rather be riding on the Tiger 800 or the Norton

  3. #3
    Join Date
    Jun 2005
    Richmond, Virginia USA
    Provided Answers: 19
    Here's some boilerplate code I have archived, modified to check the status of the Finished Date Field, before executing the Validations:

    Private Sub Form_BeforeUpdate(Cancel As Integer)
    Dim ctl As Control
    Dim CName As String
    If IsDate(Me.[Finished Date]) Then
    For Each ctl In Me.Controls
      Select Case ctl.ControlType
       Case acTextBox, acComboBox, acListBox, acCheckBox
        If Nz(ctl, "") = "" Then
         CName = ctl.Controls(0).Caption
         MsgBox "Following field is required: " & vbCrLf & vbCrLf & CName
         Cancel = True
         Exit Sub
        End If
        End Select
      Next ctl
    End If
    End Sub

    If you only needed some of the Fields to be populated, you could use similar code, but use the Tag Property to pinpoint those that need to be checked.

    Linq ;0)>
    Hope this helps!

    The problem with making anything that fools are so darn ingenious!

    All posts/responses based on Access 2003/2007

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts