Results 1 to 5 of 5
  1. #1
    Join Date
    Mar 2005
    Posts
    3

    Unanswered: Setfocus on specific record

    I have a form in continuous form mode. Each record has a button that, when clicked, uses SQL to append a record to a different table. The problem is that after you click the button, the focus always returns to the first record. This can be pretty annoying if you want to click the button on several records. Is there any way to set the focus on the last record on which you did the button click?

    If it helps to clarify, each record represents a member of an organization. When you click on the button, a record is inserted to a table that tracks attendance. Each record contains a date of attendance.

    Thanks!

  2. #2
    Join Date
    Jul 2003
    Location
    Michigan
    Posts
    1,941
    Try something along the lines of:

    Code:
    ...
    strBkMk = Me.BookMark
    'run your sql statement(s)
    Me.BookMark = strBkMk
    ...
    You may want to look at help for bookmarks, since I haven't done any coding with them in a while
    Inspiration Through Fermentation

  3. #3
    Join Date
    Sep 2003
    Location
    MI
    Posts
    3,713
    Here's an example:
    Code:
    Function FindNewContact() As Integer
        On Error GoTo Err_FNC
        
        Dim rs As Object
        
        Set rs = Me.ContactList.Form.RecordsetClone
        rs.FindFirst "[Ndx] = " & ParameterTxt.Value
        Me.ContactList.Form.Bookmark = rs.Bookmark
        Set rs = Nothing
      
        FindNewContact = 1
       
    Exit_FNC:
        Exit Function
        
    Err_FNC:
        
        MsgBox Err.Number & ": " & Err.Description
        FindNewContact = 1
        Resume Exit_FNC
    End Function
    Back to Access ... ADO is not the way to go for speed ...

  4. #4
    Join Date
    Mar 2005
    Posts
    3
    M Owen,

    I tried that and looked at posts in other forums that say basically the same thing, but nothing changes. Here's my version, based on your response and the other forum postings:

    Dim rs As Object
    Set rs = Me.RecordsetClone
    rs.FindFirst "[familyID] = " & Me.FAMILYID
    Me.Bookmark = rs.Bookmark

    I put a MsgBox in temporarily to see what Me.FamilyID was and it is the right value (we're actually tracking attendance of a family rather than an individual). When I put Me.Bookmark in a MsgBox the result is a question mark.

    The form is usinq the results of a query that joins three tables. FamilyID is a key field in the Family table. Is the problem that I would have to hit a table rather than a query?

  5. #5
    Join Date
    Mar 2005
    Posts
    3
    I found the problem. me.Requery puts the bookmark back to record #1. When I pull that, I don't need any code to do it. Live and Learn! Thanks!

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •