Results 1 to 4 of 4
  1. #1
    Join Date
    Mar 2004

    Arrow Unanswered: Detecting Blank Forms

    I've recently come faced with the problem of detecting blank forms when there are no data from the query which the form is based on. Does anyone knows how to detect a blank form using VB for Apps?

    Thx in advance. 8)

  2. #2
    Join Date
    Nov 2003
    1,487 can try this function:
    Function IsThereFormData(frm As Form) As Integer
       Dim Ctrl As Control
       For Each Ctrl In frm.Controls
          'Un-Rem lines below to check only TextBoxes.
          'If Ctrl.ControlType = acTextBox Then
             If Not IsNull(Ctrl) Then IsThereFormData = 1:Exit For
          'End If
       Next Ctrl
    End Function
    In the On Open event of your Form:
    If IsThereFormData(Me) = 0 Then
       MsgBox "No data found in Form to display"
       Cancel = True
    End If
    But in my opinion, your query should never allow for a blank form. A message should display instead indicating that there were no results from the query.

  3. #3
    Join Date
    Oct 2003
    Provided Answers: 1
    You can use the Report's OnNoData event for this. For example, the following code

    Private Sub Report_NoData(Cancel As Integer)
       MsgBox "No data found! Closing report."
       Cancel = True
    End Sub

  4. #4
    Join Date
    Mar 2004
    to hammbakka: maybe i didn't state clearly. but it is about detecting data in FORMS. thx for ur reply anyway.

    to CyberLynx: thx for ur code. i'll try it out.

Posting Permissions

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