Results 1 to 4 of 4
  1. #1
    Join Date
    Nov 2002
    Location
    Belgium
    Posts
    243

    Unanswered: Going to a certain record of a form

    I have a continious form based on a query.
    When I doubleclick a record I retrieve its recordnumber and then it will be deleted from the query.
    When I do a requery the first record is selected but I want to go back to the record with the retrieved recordnumber (that means the record which was right after the record I deleted)
    I tried this :

    Code:
    Private Sub Form_DblClick(Cancel As Integer)
        Dim clickedRecord as Integer
    
        clickedRecord = Me.currentRecord
        
        'HERE COMES THE CODE TO DELETE THE CLICKED RECORD
        
        Me.Requery
    
        Docmd.GoToRecord , , acGoTo,clickedRecord
    End Sub
    It gives me error 2105 : Could not go to specified record

    What am I missing?

  2. #2
    Join Date
    Jul 2003
    Posts
    38
    Simple: you go to the deleted record. Try to go to ClickedRecord -1

    regards

  3. #3
    Join Date
    Nov 2002
    Location
    Belgium
    Posts
    243
    Originally posted by SubHugo
    Simple: you go to the deleted record. Try to go to ClickedRecord -1

    regards
    No matter if I go to clickedRecord, clickedRecord - 1, clickedRecord + 1.
    Even when I will go to record 10 it won't work.
    --> I always get the error-message.

  4. #4
    Join Date
    Jan 2003
    Location
    Vietnam
    Posts
    188
    you can do it with bookmark, here is an extraction from my app:

    Dim tmp As String
    tmp = "ItmCode='" & ItemID & "'" 'get the next record ID
    'do something here

    Pub_fPRSub1.Form.Requery 'requery the form

    Set rst = Pub_fPRSub1.Form.RecordsetClone
    rst.FindFirst tmp
    If Not rst.NoMatch Then
    Pub_fPRSub1.Form.Bookmark = rst.Bookmark 'goto desired record
    End If

    your code will definitely different, these codes just for example

    hope this helps
    qha_vn

Posting Permissions

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