Results 1 to 2 of 2
  1. #1
    akibasaimon is offline Novice
    Windows 7 64bit Access 2010 32bit
    Join Date
    Nov 2013
    Posts
    2

    Run-time error 2105 due to no records being present

    Hi All,



    I was tasked with creating a form to show the live daily results of a query that cycles through each record and also tells the form to automatically re-query at a set interval. The live results screen is displayed on a monitor that is left on throughout the day. Data is constantly being added to the tables throughout the day (hence the need for the automatic re-query).

    I tested the form and it works fine when there is data present. The issue I have come across is at the beginning of the day when there would be no data for the query to pull. I need the live results screen to remain on (ready for when data has been entered) but not error out if there isn't any data.

    Here's the coding for the form with the error occurring on the line highlighted in red:
    Code:
    Option Compare Database
    
    Private Sub Form_Close()
    
    
    DoCmd.OpenForm "frm_Live_Defects_VS_1_Cal_b"
    End Sub
    
    
    
    
    
    
    Private Sub Form_Timer()
      Static intCount As Integer
      intCount = intCount + 1
      
      If intCount = 5 Then
      'On form timer event requery form
      Me.Requery
    
    
      Else
      On Error GoTo ErrorHandler
    
    
      DoCmd.GoToRecord , , acNext
    
    
    ExitHandler:
      Exit Sub
    
    
    ErrorHandler:
      Select Case Err
        Case 2105    'end of data
          DoCmd.GoToRecord , , acFirst
        Case Else
          MsgBox Err.Description
          DoCmd.Hourglass False
          Resume ExitHandler
      End Select
      
      If intCount > 6 Then
      'reset intCount to 0
      intCount = 0
      
      End If
      
      
      End If
      
      
    End Sub

    Any ideas on how I can solve this issue?

  2. #2
    rpeare is offline VIP
    Windows XP Access 2003
    Join Date
    Jul 2011
    Posts
    5,442
    I assume there is a query driving this form and it's not coming directly from a table, if that's the case you can do something like:

    Code:
    if dcount("*", "[QueryName]") <>0  then
        DoCmd.GoToRecord , , acNext
    endif

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

Similar Threads

  1. Replies: 13
    Last Post: 12-12-2013, 11:04 AM
  2. Replies: 10
    Last Post: 10-22-2013, 07:35 AM
  3. Replies: 5
    Last Post: 08-22-2012, 04:27 AM
  4. Replies: 1
    Last Post: 06-04-2012, 03:37 PM
  5. Replies: 5
    Last Post: 03-30-2010, 12:53 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