Hello everyone,
I've been peeling through an onion of a database and can't seem to crack this one. The database is broken. It will not generate a new number. I get an error that says "Can't go to specified record." Unfortunately this isn't something that is accounted for within the programming that the developer left behind.
Code:
sFormName = "frmNewGNumber"sQueryName = "GNumbers"
sSwitch11FormName = "frmSpecialG4"
sSwitch12FormName = "frmSpecialG3"
iLocation = 1
If IsNull(SwitchType) Then
'switch type has not been chosen
Me.EndingOption = txtSwitchTextBox
Me![Location] = iLocation
RecordNum1 = Me.RecordID
'open form of available numbers
DoCmd.OpenForm sFormName, , , , , acWindowNormal
'does an available switch number exist?
If Forms(sFormName).CurrentRecord = 0 Then
'no switch number exists -> exit subroutine
MsgBox ("No switch numbers ending in " & txtSwitchTextBox & " available for this area")
GoTo EndCode
End If
'display new switch number and remove from table of available switches
Call RemoveNumberFromTable(sFormName, sQueryName, 1)
'close forms, and queries
DoCmd.Close acForm, sFormName, acSaveNo
Dim sQueryClose As String
sQueryClose = sQueryName & " Without Matching qryMPCSwitches5"
DoCmd.Close acQuery, sQueryClose, acSaveNo
'''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
''search for three consecutive switches ending in 5, 6, and 9
'''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
ElseIf (SwitchType = 12) Then
'open form of available numbers
DoCmd.OpenForm sSwitch12FormName, , , , , acWindowNormal
'does a sequence of three numbers exist?
If Forms(sSwitch12FormName).CurrentRecord = 0 Then
'no sequence of numbers exist -> exit subroutine
MsgBox ("No switch numbers available that fit specified sequence")
GoTo EndCode
End If
'make sure starting switch number ends in 5
Do While Right(Forms(sSwitch12FormName)![Numbers], 1) <> 5
'switch does not end in 5 get next switch in table
DoCmd.GoToRecord acDataForm, sSwitch12FormName, acNext
Loop
''''''''''''''''''''''''''''''''''''''''''''''''''''
'1st Record
''''''''''''''''''''''''''''''''''''''''''''''''''''
Me![EndingOption] = 12
Me![Location] = iLocation
RecordNum1 = Me.RecordID
'display new switch number and remove from table of available switches
Call RemoveNumberFromTable(sSwitch12FormName, sQueryName, 1)
'goto next record
DoCmd.GoToRecord acDataForm, sSwitch12FormName, acNext
DoCmd.GoToRecord , , acNext
''''''''''''''''''''''''''''''''''''''''''''''''''''
'2nd Record
''''''''''''''''''''''''''''''''''''''''''''''''''''
Me![EndingOption] = 12
Me![Location] = iLocation
RecordNum2 = Me.RecordID
'display new switch number and remove from table of available switches
Call RemoveNumberFromTable(sSwitch12FormName, sQueryName, 2)
'goto next record
DoCmd.GoToRecord acDataForm, sSwitch12FormName, acNext
DoCmd.GoToRecord , , acNext
''''''''''''''''''''''''''''''''''''''''''''''''''''
'3rd Record
''''''''''''''''''''''''''''''''''''''''''''''''''''
Me![EndingOption] = 12
Me![Location] = iLocation
RecordNum3 = Me.RecordID
'display new switch number and remove from table of available switches
Call RemoveNumberFromTable(sSwitch12FormName, sQueryName, 3)
'close forms, and queries
DoCmd.Close acForm, sSwitch12FormName, acSaveNo
DoCmd.Close acQuery, sQueryName
'end ElseIf (SwitchType = 12)
'''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
Are there any ideas as to why this isn't working?