Results 1 to 6 of 6
  1. #1
    Join Date
    Feb 2002
    Posts
    55

    Unhappy Unanswered: No results found Part 2

    I am currently putting together an Access frontend for an Oracle DB. I have a search engine piece that is based on keywords and/or category selections.

    When I perform my search, if there are no results found in the database, the results page will come across as completely blank. There will be no fields or such.

    I would like to have a box pop up stating "no results found," but can't seem to get an if statement working where if a QuestionID is null or "" a message box will pop up.

    Any input would be appreciated,

    TIA

    Hirk

  2. #2
    Join Date
    Nov 2001
    Posts
    336
    Hi,

    I hope the link below will help to solve your problem:

    http://www.mvps.org/access/forms/frm0029.htm

    Igor

  3. #3
    Join Date
    Feb 2002
    Posts
    55
    There is no subform, just the main form, so I altered the code as shown and placed it on the "On Current."

    Private Sub Form_Current()
    With Forms!RFPAnswers
    .Visible = (.RecordsetClone.RecordCount > 0)
    End With
    End Sub

    The result is that the form shows up, but none of the fields appear on the form and you can't perform any type of navigation.

    Thanks,

    Hirk

  4. #4
    Join Date
    Nov 2001
    Posts
    336
    It happens when there is no any records in form's datasource.

    Try this code:

    Private Sub Form_open()

    if me.RecordsetClone.RecordCount = 0 then
    msgbox "No records to show."
    end if

    End Sub

    Igor

  5. #5
    Join Date
    Feb 2002
    Posts
    55
    That seems to have done the trick... I still couldn't get the dataless form to close (runtime 2825 errors), so I set it to show all records when this occurs and it works great. Thanks!!!

  6. #6
    Join Date
    Nov 2001
    Posts
    336
    Hi,

    Form load event has a parameter, which can be usefull for you:

    Private Sub Form_Open(Cancel As Integer)
    if me.RecordsetClone.RecordCount = 0 then
    cancel=true
    msgbox "No data. Press OK to continue."
    end if
    End Sub

    In order to open such form use the following simplified code:

    Private Sub CmdOpenForm_Click()
    on error resume next
    DoCmd.OpenForm "frmMyCoolForm"
    End Sub

    Igor

Posting Permissions

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