Results 1 to 3 of 3
  1. #1
    JackieEVSC is offline Advanced Beginner
    Windows 7 32bit Access 2007
    Join Date
    Oct 2011
    Posts
    70

    Blank screen on empty query

    I'll try explaining what I'm doing and hope I do a better job this time.

    I have a form that allows users to query the RepairInfo table, which only includes schools they've selected in the MySchools table.

    One of the fields they can choose to search on is the repair ticket number (TicketNum). Clicking on the button the search by ticket number has this underlying code:

    Private Sub Command162_Click()
    DoCmd.Close acForm, "frm_RepairInfo-Asset"
    DoCmd.OpenForm "frm_RepairInfo-Ticket"
    End Sub



    If they enter a ticket number not in the table, it currently goes to a blank screen. Because I've already closed the form they were on and the db structure is hidden, the only way to recover is to close and reopen the program.

    If the criteria they enter yeilds no results, I need a message box to pop up, then when they click "ok", to have it go to the frm_RepairInfo form, which is the only form with the search buttons that is not based on a search query.

    I've received some help that gave me the code where I could paste the SQL code form the query, but believe a JOIN and an ORDERBY statement in the query is causing it to fail. In the module, the code in the shows red for JOIN and ORDERBY statement.

    I know someone who knows vba could accomplish this in seconds, but I'm really struggling with it! I know it's not a difficult thing to do, but I'm lost! Help!

  2. #2
    June7's Avatar
    June7 is online now VIP
    Windows XP Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    52,931
    Don't let them enter a ticket number not in the table. Use a combobox with RowSource listing ticket numbers.

    Or validate the entry in the AfterUpdate event of the box with DLookup() function. Like:
    If IsNull(DLookup(...)) Then
    Msgbox "No such number."
    'open RepairInfo form
    Else
    'code to open other form - instead of button click
    End If
    How to attach file: http://www.accessforums.net/showthread.php?t=70301 To provide db: copy, remove confidential data, run compact & repair, zip w/Windows Compression.

  3. #3
    JackieEVSC is offline Advanced Beginner
    Windows 7 32bit Access 2007
    Join Date
    Oct 2011
    Posts
    70
    I changed the form to "Yes" for allow additions which allows the it brings up an empty form. It's not what I was striving for, but it keeps them in the program and allows them to search again, so I'm going to quit banging my head against the wall and call it good enough! Thank you!

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

Similar Threads

  1. Replies: 4
    Last Post: 11-20-2011, 01:08 PM
  2. Replies: 11
    Last Post: 06-05-2011, 09:51 PM
  3. Controls go blank on empty query result
    By kevdfisch in forum Programming
    Replies: 4
    Last Post: 08-25-2009, 08:07 AM
  4. Replies: 1
    Last Post: 09-05-2008, 12:07 PM

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