[AccessD] Datasheet view validation

A.D.Tejpal adtp at touchtelindia.net
Mon Apr 4 11:56:07 CDT 2005


JR,

    Your objective can be met by placing the code block given below, in form's Unload event. FldRight is the name of field on many side of the join.

    An attempt to close the form while field FldRight is yet to be filled up in any of the records, will result in a message box stating the number of such entries which are still awaited. Once the message box is acknowledged, the cursor will move to the first record having blank FldRight awaiting entry.

    As an added effect, you could consider highlighting such blank fields in special color, through conditional formatting.

Best wishes,
A.D.Tejpal
--------------

=====================================
Private Sub Form_Unload(Cancel As Integer)
    Dim rst As DAO.Recordset
    Dim RecSource As String, Blanks As Long
    
    Me.Dirty = False
    RecSource = Me.RecordSource
    Blanks = DCount("*", RecSource, _
                                    "FldRight Is Null")
    If Blanks > 0 Then
        Set rst = Me.RecordsetClone
        MsgBox Blanks & " Entries Still " & _
                                "Pending In Field FldRight"
        rst.FindFirst "FldRight Is Null"
        If Not rst.NoMatch Then
            Me.Bookmark = rst.Bookmark
            FldRight.SetFocus
        End If
        Set rst = Nothing
        Cancel = True
    End If
End Sub
=====================================

  ----- Original Message ----- 
  From: Joe Rojas 
  To: 'Access Developers discussion and problem solving' 
  Sent: Monday, April 04, 2005 18:25
  Subject: [AccessD] Datasheet view validation


  Hi All,

  I have a form that has as its record source a query that joins two tables together in a one-to-many relationship (outer join). I am displaying this form as a datasheet.
  The query is designed so that there will never be any records that match on the "many" side when it is first opened. The query only displays two columns. One from the "one" side and one from the "many" side.
  As I have it now, a user could close the form without entering data into the field from the "many" side, thus not creating a record on the "many" side.

  How can I verify that the user has entered data in the field from the "many" side for every record that is displayed? I don't want to restrict the row order in which they enter data but I do want to make sure that the field for each row is filled in before they close the form.

  Thanks!
  JR



More information about the AccessD mailing list