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