Results 1 to 4 of 4
  1. #1
    Dulanic is offline Novice
    Windows 7 64bit Access 2007
    Join Date
    Mar 2012
    Posts
    4

    Load form from datasheet and set focus

    Hello,



    I am trying to load a double clicked record within a datasheet on the form. I am using the following to load the record:

    Code:
    Private Sub assoc_name_DblClick(Cancel As Integer)
        Dim stDocName As String
        Dim stLinkCriteria As String
        stDocName = "frm_error_entry"
        stLinkCriteria = "[ID]=" & Me![ID]
        DoCmd.OpenForm stDocName, , , stLinkCriteria
        Forms![frm_error_entry].SetFocus
    End Sub
    This is kind of funky... sometimes when I double click the record it loads the form blank on a new record instead of allowing us to edit the matching record in the original entry form. The other issue is, the .setfocus is acting up too... the form gets loaded but then it goes back to the form the record was double clicked on instead of stating focus on frm_error_entry. Is there a better way to take care of this? I verified there is no code on load/focus etc that would be throwing focus back to the original form.

    Any ideas?

  2. #2
    RuralGuy's Avatar
    RuralGuy is offline Administrator
    Windows 7 64bit Access 2010 32bit
    Join Date
    Mar 2007
    Location
    8300' in the Colorado Rocky Mountains
    Posts
    12,922
    Use the acDialog argument to hold the focus on the next form until it is closed or hidden

  3. #3
    Dulanic is offline Novice
    Windows 7 64bit Access 2007
    Join Date
    Mar 2012
    Posts
    4
    Sorry for not ever closing or replying to this thread until now. I did try that and it still did not work, it would open the window behind the datasheet/form that I was double clicking to open the record.

  4. #4
    RuralGuy's Avatar
    RuralGuy is offline Administrator
    Windows 7 64bit Access 2010 32bit
    Join Date
    Mar 2007
    Location
    8300' in the Colorado Rocky Mountains
    Posts
    12,922
    If you are using the acDialog argument then you could set the Visible property to False before opening the next form and back to True as the next line after opening the 2nd Form.

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

Similar Threads

  1. Replies: 1
    Last Post: 02-29-2012, 09:38 AM
  2. Replies: 2
    Last Post: 08-22-2011, 09:02 PM
  3. Run macro on form load?
    By stu_C in forum Forms
    Replies: 3
    Last Post: 08-16-2011, 07:54 AM
  4. Instant load of a form
    By carstenhdk in forum Forms
    Replies: 2
    Last Post: 05-06-2010, 12:27 AM
  5. On Load, form not visible
    By Bruce in forum Forms
    Replies: 15
    Last Post: 02-24-2010, 04:06 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