Results 1 to 6 of 6
  1. #1
    Star Lounger
    Join Date
    Jan 2002
    Location
    Massachusetts, USA
    Posts
    87
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Form Problem (2002(XP))

    I have a form based in a parameter query. If there are no records that match the query then the form shows blank. No Bound or unbound controls no command buttons nothing. I would like it to display a message that no records matched and have a button to go back to the switchboard. Any Help appreciated.

    Thanks,
    Ed

  2. #2
    Plutonium Lounger
    Join Date
    Dec 2000
    Location
    Sacramento, California, USA
    Posts
    16,775
    Thanks
    0
    Thanked 1 Time in 1 Post

    Re: Form Problem (2002(XP))

    In the OnOpen event of the form, check the underlying recordset to see if it is at EOF. If it is, there are no records, so you can Cancel the event and pop up a messagebox saying there are not matching records.
    Charlotte

  3. #3
    Star Lounger
    Join Date
    Jan 2002
    Location
    Massachusetts, USA
    Posts
    87
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Form Problem (2002(XP))

    Do I use a macro. If so I looked and I didn't see any kind of if statement. I just started using macros and am not fully versed on them

    Thanks,
    Ed

  4. #4
    Plutonium Lounger
    Join Date
    Dec 2000
    Location
    Sacramento, California, USA
    Posts
    16,775
    Thanks
    0
    Thanked 1 Time in 1 Post

    Re: Form Problem (2002(XP))

    You can't do it with a macro in the Access sense of that word. You need code to open a recordset.
    Charlotte

  5. #5
    Gold Lounger
    Join Date
    Feb 2001
    Location
    Sint Niklaas, Belgium
    Posts
    2,778
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Form Problem (2002(XP))

    In the on open event of your for put this code:
    <pre>Private Sub Form_Open(Cancel As Integer)
    If Me.Recordset.RecordCount = 0 Then
    MsgBox "There are no records for this form."
    Cancel = True
    End If
    End Sub</pre>

    Francois

  6. #6
    Star Lounger
    Join Date
    Jan 2002
    Location
    Massachusetts, USA
    Posts
    87
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Form Problem (2002(XP))

    Awesome!! That did the trick

Posting Permissions

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