Wrox Programmer Forums
|
Access Discussion of Microsoft Access database design and programming. See also the forums for Access ASP and Access VBA.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the Access section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old June 16th, 2004, 11:04 PM
Authorized User
 
Join Date: Jun 2004
Posts: 39
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via AIM to Raif
Default can't get bookmarks to work

Hi, I can't seem to make bookmarks work. I set up a recordset rs and a clone rsclone. I do a findfirst and then add a record if nomatch. then I need to requery I want the new record to be displayed on the form. I've tried setting a strbookmark string, then what seems like every concievable combination of strbookmark,rs.bookmark,rsclone.bookmark,and rs.lastmodified with = sings mixed in and the result is allways the same which is that the form adds it's record then goes to the first record.
Any help would be appreaciated.
Thanks
Raif

 
Old June 17th, 2004, 03:10 AM
Friend of Wrox
 
Join Date: Jun 2003
Posts: 1,093
Thanks: 1
Thanked 12 Times in 11 Posts
Default

After adding the new record via the AddEntry procedure below, assign the recordsets LastModified property value to the recordsets Bookmark property. This will make you new record the currently displayed record.

Private Sub txtCriteria_AfterUpdate()
    Dim rst As DAO.Recordset
    Dim strCriteria As String

    strCriteria = "[ID] = " & Me![txtCriteria]

    Set rst = Me.RecordsetClone
    rst.FindFirst strCriteria
    If rst.NoMatch Then
        MsgBox "No entry found. The record will be added.", vbInformation
        Call AddEntry(rst, Me![txtCriteria])
    Else
        Me.Bookmark = rst.Bookmark
    End If

    Set rst = Nothing
End Sub

Sub AddEntry(rstTemp As Recordset, newEntry As String)

    ' Adds a new record and set the recordsets Bookmark
    ' at the LastModified record.
    With rstTemp
        .AddNew
        !TestData = newEntry
        .Update
        .Bookmark = .LastModified
    End With
End Sub

HTH,

Bob






Similar Threads
Thread Thread Starter Forum Replies Last Post
Alternative to BOOKMARKS Shiamak Word VBA 2 October 31st, 2008 04:04 PM
Form and bookmarks in Word paul20091968 Word VBA 0 May 16th, 2006 09:09 AM
add a image as your 'avatar' for bookmarks crmpicco HTML Code Clinic 4 September 30th, 2005 03:51 AM
can't get bookmarks to work Raif Access VBA 2 June 17th, 2004 09:25 AM
Replacing Word Bookmarks from VB pavel Pro VB 6 0 May 3rd, 2004 09:20 AM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.