Results 1 to 7 of 7
  1. #1
    Join Date
    Sep 2003
    Posts
    83

    Unanswered: Forms with no data

    Good Morning,

    How can we inform the user that there is no data in the form.
    In reports we have the "Report_NoData(Cancel As Integer)" event, where we can write the code to display a message box.
    Can something similar be achieved in Forms also, if there is no data for some criteria.

    Any suggestions will be greatly appreciated.
    Thanks in advance.

  2. #2
    Join Date
    Dec 2002
    Location
    Préverenges, Switzerland
    Posts
    3,740
    no data means the recordset (recordsetclone too i guess, though i don't show forms till i know i have data) is .BOF and .EOF and .recordcount=0

    izy
    currently using SS 2008R2

  3. #3
    Join Date
    Sep 2003
    Posts
    83

    Forms with no data

    I also need similar like this. What is happening right now in my case is the form is showing a blank window, if there is no data. Instead I want to display a message box to the user saying there is no data for this. How can we achieve this? can you please give more info.
    Thanks in advance

  4. #4
    Join Date
    Sep 2003
    Location
    MI
    Posts
    3,713
    Quote Originally Posted by skodidhi
    I also need similar like this. What is happening right now in my case is the form is showing a blank window, if there is no data. Instead I want to display a message box to the user saying there is no data for this. How can we achieve this? can you please give more info.
    Thanks in advance
    Quetion is: WHEN do you want to inform them? Before the form displays or after?

  5. #5
    Join Date
    Dec 2002
    Location
    Préverenges, Switzerland
    Posts
    3,740
    one simple way:

    detail section of the form is hidden in design view
    footer section has a label "select an entry Oh foolish user"

    ...gives you time on _Load() to check if there are records, and if yes, hide the footer and show the detail.

    izy
    currently using SS 2008R2

  6. #6
    Join Date
    Sep 2003
    Posts
    83
    I would like to display a message box before the form displays.

    The database is secured. The form recordsource is based on the Currentuser(). so what I need is to display the messagebox that there is no data, before the form displays.
    Thanks.

  7. #7
    Join Date
    Apr 2004
    Location
    Sydney Australia
    Posts
    369
    Make a query that will produce a null result since there are no records but make the query have a criteria applied to a field that must have an entry when a record is present.

    Make a form based on this query and put two overlaying labels such as No Data and Data Available and set then as invisible.

    Have a macro open this form and "on open" or "on current" have a macro that sets the visible property of the appropriate label and for a condition have
    [Forms]![MyForm][Field] Is Null
    [Forms]![MyForm][Field] Is Not Null
    The last will work if the field you refer to always has an entry if there is a record.

    Then attach a macro to the appropriate label which will either close this form down or if there is data then the label Data Available will have a macro that opens the form with the data and closes down the first form.

    PS. I just tried that but it would not work when there were no records.

    What could be done is for a dummy record to always be in the table but the query supporting the form can't display it due to criteria. You could then use a "count" for conditions where the count is 1 or greater than 1 etc. That is, when the count is greater than 1 there is at least one true record present

    PS it did work with no records. My form was so rough I did not notice it was working I had two tiny labels On and Off and greay back ground and they were right next to each other.

    Mike
    Last edited by Mike375; 04-30-04 at 14:23.

Posting Permissions

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