Results 1 to 4 of 4
  1. #1
    flantrains is offline Novice
    Windows 7 64bit Access 2010 64bit
    Join Date
    Dec 2019
    Location
    Walt Disney World
    Posts
    2

    Run-time error 2105

    First form frm_Searching runs thru the tbl_Scanners table sequentially and links to the second form frm_Scanning which computes the range between the two entries and reports accordingly. The problem I am encountering is that when the second form returns control to the first form and I request the next record in the tbl_Scanners table I get the following error: "Run-time error '2105': You can't go to the specified record."
    How do I change my code to accomplish my goal of processing thru the tbl_Scanners table entirely?
    Thanks for all the help,
    Bill

    ================================================== ================================
    =========================== First form "frm_Searching" =====================================



    Option Compare Database

    Private Sub Form_Load()
    Dim stDocName As String
    stDocName = "del_Sightings"
    DoCmd.OpenQuery stDocName, , acEdit
    DoCmd.OpenTable "tbl_Scanners"
    DoCmd.GoToRecord acDataTable, "tbl_Scanners", acFirst
    Form_Loop:
    If UN_Empire = "ZZZ" Then
    GoTo Form_Exit
    End If
    stDocName = "frm_Scanning"
    DoCmd.OpenForm stDocName
    Form_Next:
    DoCmd.GoToRecord acDataTable, "tbl_Scanners", acNext
    GoTo Form_Loop
    Form_Exit:
    DoCmd.Close
    End Sub


    ================================================== ===============================
    ========================= Second form "frm_Scanning" =====================================
    Option Compare Database

    Private Sub Form_Load()
    Dim stDocName As String
    Dim FM_X, FM_Y, TO_X, TO_Y, ABS_X, ABS_Y As Integer
    DoCmd.OpenTable "tbl_Units"
    DoCmd.GoToRecord acDataForm, "frm_Scanning", acFirst
    Form_Loop:
    If UN_Empire = "ZZZ" Then
    GoTo Form_Exit
    End If
    If UN_Empire = "CIV" Then
    GoTo Form_Next
    End If
    If UN_Empire = Scan_Empire Then
    GoTo Form_Next
    End If
    If UN_Orders = "B" Or UN_Orders = "R" Then
    GoTo Form_Next
    End If
    Scan_Range = 8 + Scan_Scouts + Int(UN_CurrSpeed / 2)
    If Scan_Science = "Y" Then
    Scan_Range = Scan_Range + 1
    End If
    If UN_Stealth = "Y" Then
    Scan_Range = Scan_Range - 2
    End If
    If UN_Cloak = "Y" And UN_Curr_Speed <= 9 Then
    Scan_Range = Scan_Range - 2
    End If
    If UN_Curr_Speed = 0 Then
    Scan_Range = Scan_Range - 2
    End If
    FM_X = Int(Scan_Location / 100)
    FM_Y = Scan_Location - (FM_X * 100)
    TO_X = Int(UN_Curr_Loc / 100)
    TO_Y = UN_Curr_Loc - (TO_X * 100)
    ABS_X = Abs(FM_X - TO_X)
    ABS_Y = Abs(FM_Y - TO_Y)
    Actual_Range = Int(Sqr((ABS_X * ABS_X) + (ABS_Y * ABS_Y)))
    If Scan_Range < Actual_Range Then
    GoTo Form_Next
    End If
    stDocName = "app_Sighting"
    DoCmd.OpenQuery stDocName, , acEdit
    Form_Next:
    DoCmd.GoToRecord acDataForm, "frm_Scanning", acNext
    GoTo Form_Loop
    Form_Exit:
    DoCmd.Close
    End Sub

  2. #2
    June7's Avatar
    June7 is online now VIP
    Windows 10 Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    52,822
    Use acDialog parameter:

    DoCmd.OpenForm stDocName, , , , , acDialog

    This suspends code execution on first form until second form closes.

    For future, please post lengthy code between CODE tags to retain indentation and readability.
    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
    flantrains is offline Novice
    Windows 7 64bit Access 2010 64bit
    Join Date
    Dec 2019
    Location
    Walt Disney World
    Posts
    2
    Quote Originally Posted by June7 View Post
    Use acDialog parameter:

    DoCmd.OpenForm stDocName, , , , , acDialog

    This suspends code execution on first form until second form closes.

    For future, please post lengthy code between CODE tags to retain indentation and readability.
    Added the suggested code, but the second form does not close normally. When I 'hard' close it (CLOSE ALL) it finally returns to the first form with the following error:

    "Run-Time error 2046 The command or action "GoToRecord" isn't available now"

    Any other ideas and thanks for the help in advance.

  4. #4
    June7's Avatar
    June7 is online now VIP
    Windows 10 Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    52,822
    I've never seen a loop set up like that. GoTo is considered less desirable branching technique. I have only used it for error handling code. However, it looks like it should work. Have you step debugged?

    Are you trying to loop through records of each form?

    Why are you opening tables and a queries?

    If you want to provide db for analysis, follow instructions at bottom of my post.
    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.

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

Similar Threads

  1. Replies: 7
    Last Post: 09-13-2017, 06:36 AM
  2. Error 2105 all of a sudden
    By TaliaKlein in forum Forms
    Replies: 7
    Last Post: 11-09-2015, 10:47 AM
  3. Replies: 1
    Last Post: 01-10-2014, 09:51 AM
  4. Replies: 10
    Last Post: 10-22-2013, 07:35 AM
  5. Replies: 1
    Last Post: 06-04-2012, 03:37 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