SetFocus gives "can't go to specified record" error

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • Shawn29316
    New Member
    • Feb 2007
    • 33

    SetFocus gives "can't go to specified record" error

    I am trying to do such a simple (and devilishly frustrating) task.
    I want to hide fields on a subform when the main form opens. Once a value is chosen from a combo box in the main form, the corresponding subform values will become visible.
    I've read a lot on the subject and most folks say to create a "dummy" field or button on the form and set the focus on that object. I've tried that with a button named Command58 but I get the "can't go to specified record" when I open the form. Here's my code:
    Code:
    Private Sub Form_Load()
    Call JBModule.VisOff1
    End Sub
    
    'located in the JBModule
    Public Sub VisOff1()
    
    Forms!SelectJob.BidResults.Form!Command58.SetFocus
    
    Forms!SelectJob.BidResults.Form!EmplID.Visible = False
    
    End Sub
    I would appreciate any help you might be able to give me. I know this is novice stuff for you but it's making me feel awfully stupid right now!
  • jimatqsi
    Moderator Top Contributor
    • Oct 2006
    • 1288

    #2
    The problem is not in this code. You could comment out all of this and still have the problem. What does the recordset look like? What is in the other form events? How are the main and subforms linked?

    Hard to tell which form the problem is in. Copy your main form. In the copy, delete the subform and any references to it. Launch the copied form and see if you still have the problem.

    Jim

    Comment

    • Shawn29316
      New Member
      • Feb 2007
      • 33

      #3
      I really don't know how to explain the recordset. The main form's Record Source is "SELECT T_JB_JobDetail. * FROM T_JB_JobDetail; " and the source for the subform is a query whose SQL I'm pasting here.
      Code:
      SELECT DISTINCT TOP 1 T_JB_Bid_Winners.EmplID, T_JB_Bid_Winners.BidFromJobID, T_JB_Bid_Winners.BidToJobID, T_JB_Bid_Winners.Name, T_JB_Bid_Winners.[Total Points], T_JB_Bid_Winners.Title, T_JB_Bid_Winners.RecID, T_Wage_Report.FirstOfGRADE555 AS CurrLevel, T_JB_Bid_Winners.ActivityDate, T_Wage_Report.FirstOfCO_SVC_DT, T_Wage_Report.SALPLAN
      FROM T_JB_Bid_Winners INNER JOIN T_Wage_Report ON T_JB_Bid_Winners.EmplID = T_Wage_Report.ID
      WHERE (((T_JB_Bid_Winners.ActivityDate) Is Null Or (T_JB_Bid_Winners.ActivityDate)<Date()-365));
      I don't understand the suggestion to copy the form, delete the subform and see if the problem goes away. If I delete the subform, won't the problem automatically go away since I'm setting focus to an object on the subform? Please accept that I'm not being contentious, I'm trying to learn!

      Does it help to know that I changed the event that triggers the code with the same result? Instead of calling it from the OnLoad of the main form, I moved it to the OnLoad of the subform and the got the same error.

      Comment

      • jimatqsi
        Moderator Top Contributor
        • Oct 2006
        • 1288

        #4
        Did you remove the code completely, like I suggested? That code is not causing your problem. That code does nothing with record navigation.

        Run the main form and the subform independently of each other to prove each is okay by itself. I suspect something in the linkage of the two forms may be causing the problem.

        Comment

        Working...