Results 1 to 4 of 4
  1. #1
    AccessPower's Avatar
    AccessPower is offline Competent Performer
    Windows 10 Access 2013 64bit
    Join Date
    Oct 2016
    Posts
    165

    Can't go to specified record

    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?

  2. #2
    pbaldy's Avatar
    pbaldy is offline Who is John Galt?
    Windows XP Access 2007
    Join Date
    Feb 2010
    Location
    Nevada, USA
    Posts
    22,521
    What line throws the error? You may need to temporarily comment out an "On Error..." line. I'm not a fan of using forms like that, in part because it makes it hard to debug (I'd probably have a function(s) that did the testing). On of those "GoToRecord lines is trying to push a form where it can't go.
    Paul (wino moderator)
    MS Access MVP 2007-2019
    www.BaldyWeb.com

  3. #3
    AccessPower's Avatar
    AccessPower is offline Competent Performer
    Windows 10 Access 2013 64bit
    Join Date
    Oct 2016
    Posts
    165
    There aren't any lines that throw an error. I think it's an underlying issue.

    Queries based on queries based on queries based on tables. The entire thing revolves around the generation of numbers based on location. A number is chosen from an available list of numbers for each location based on a specified criteria (three consecutive matching numbers, or four, or ending in certain numbers) the number chosen is taken from the available numbers, deleted from one of like 9 tables, and placed in some other table (possibly).

    The entire thing could have easily been done in two tables.

    Update: The numbers that match the criteria are all used up. You're right... the gotorecord can't go there because there isn't any THERE to which it can go.

    This database is creating forms based on queries during an onclick event.

  4. #4
    pbaldy's Avatar
    pbaldy is offline Who is John Galt?
    Windows XP Access 2007
    Join Date
    Feb 2010
    Location
    Nevada, USA
    Posts
    22,521
    Glad you found the problem. Some line was throwing the error, or you wouldn't have gotten it. My guess is that there's an active error handler, so you weren't offered the debug option.
    Paul (wino moderator)
    MS Access MVP 2007-2019
    www.BaldyWeb.com

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

Similar Threads

  1. Replies: 4
    Last Post: 05-27-2016, 10:02 AM
  2. Replies: 4
    Last Post: 01-12-2016, 02:49 PM
  3. Replies: 3
    Last Post: 03-09-2013, 10:39 AM
  4. Replies: 3
    Last Post: 02-06-2013, 07:23 PM
  5. Replies: 2
    Last Post: 12-21-2012, 01:57 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