Results 1 to 3 of 3
  1. #1
    markyboy171 is offline Novice
    Windows XP Access 2003
    Join Date
    Jun 2012
    Posts
    5

    Question Blank form

    Im Sure you have all heard this before but this is slightly different. I have textboxes bound to a query but when the query returns no results the form will go blank. I hate navigating to a blank record so i cant just set allow additions to "YES"(This does solve the problem BTW). How can i catch this bug so it will not make my form blank when no records are returned



    Thanks in advance

  2. #2
    pbaldy's Avatar
    pbaldy is offline Who is John Galt?
    Windows XP Access 2007
    Join Date
    Feb 2010
    Location
    Nevada, USA
    Posts
    22,642
    If you want to stop the form opening, in the code that opens it test the query with DCount() and only open the form if the result is greater than 0.
    Paul (wino moderator)
    MS Access MVP 2007-2019
    www.BaldyWeb.com

  3. #3
    Missinglinq's Avatar
    Missinglinq is offline VIP
    Windows 7 64bit Access 2007
    Join Date
    May 2012
    Location
    Richmond (Virginia, not North Yorkshire!)
    Posts
    3,018
    You say what you do not want to happen, but you don't really say what you do want to happen, if the RecordSet is empty.

    To simply pop a message and close the Form, as Paul suggested, without the Form showing up
    Code:
    Private Sub Form_Open(Cancel As Integer)
    
    Dim Msg As String
    Dim intX As Integer
    
    intX = DCount("[YourPKField]", "YourTableName")
     If intX < 1 Then
       
       DoCmd.Close acForm, "YourFormName"
       
       Msg = "There Were No Records Returned By This Query"
       
       MsgBox Msg, vbOKOnly + vbInformation
         
    End If
    
    End Sub


    Linq ;0)>

Please reply to this thread with any new information or opinions.

Similar Threads

  1. Form loads blank
    By sweetiepie in forum Forms
    Replies: 5
    Last Post: 06-07-2012, 02:34 PM
  2. How to open a blank form?
    By WhatnThe in forum Access
    Replies: 15
    Last Post: 08-05-2011, 02:41 PM
  3. Replies: 2
    Last Post: 07-26-2011, 08:26 AM
  4. Form view blank
    By reidn in forum Forms
    Replies: 1
    Last Post: 06-24-2011, 11:26 AM
  5. I want my form to open blank
    By uneek78 in forum Forms
    Replies: 10
    Last Post: 01-12-2011, 01:01 PM

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Other Forums: Microsoft Office Forums