Results 1 to 4 of 4
  1. #1
    Join Date
    Mar 2002
    Posts
    7

    Unhappy Unanswered: Me.Bookmark = Me.RecordsetClone.Bookmark = Form opening on new record

    Hello there,

    I am attempting to open a form based upon a user's selection of a record that appears in a listbox on another form. Everything seems to be working fine, but when I attempt to open up the form on the record that I want to go to, the form is opening on a new record, and not on the record in the recordset that I have bookmarked. I am using the code below:

    Private Sub cmdGotoRecord_Click()

    Dim varRecordNum

    If Not IsNull(lstRecords) Then

    varRecordNum = Me!lstRecords.Column(11)

    DoCmd.OpenForm "frmEnrollmentRevisions"

    Me.RecordsetClone.FindFirst "[RecordNum] = " & varRecordNum

    Me.Bookmark = Me.RecordsetClone.Bookmark

    DoCmd.Close acForm, "frmRequestRecordSelector"

    End If
    End Sub

    I have checked to see that the values in the recordset underlying the form are returning the correct values, but it continues to open on the new record. Any ideas?

    Thanks,

    Tom

  2. #2
    Join Date
    May 2002
    Location
    Atlanta, GA
    Posts
    117
    Hello,

    I myself use a lot of List Boxes to show data. But, I use the Double-Click Event of the List Box to open a form to the correct record. Here is an example if you would like to change your code:

    Private Sub ListBox_DblClick(Cancel As Integer)
    Dim ctl As Control
    Dim varItem As Variant
    Dim Filter As Variant
    If Me.ListBox.ItemsSelected.Count = 0 Then
    MsgBox "No selection was made", vbInformation, "Message"
    ElseIf Me.ListBox.ItemsSelected.Count > 1 Then
    MsgBox "You may only select one record to view", vbInformation, "Message"
    Else
    Set ctl = Me.ListBox
    For Each varItem In ctl.ItemsSelected
    Filter = ctl.ItemData(varItem)
    Filter = "RecordNum=" + Filter
    Next varItem
    DoCmd.OpenForm "frmEnrollmentRevisions", , , Filter
    End If
    End Sub

    If necessary, you can add a close event after the Open Form event to close the initial form. If you have any questions let me know.

    Kal

  3. #3
    Join Date
    Mar 2002
    Posts
    7
    Thanks for the Response, but it is not exactly what I am looking to do.
    For one thing, I did not really want to open the form using a filter.

    If that is the only choice I have, then I suppose I could swing it. But also, the RecordNum field is not displayed on my form--I could do it with a filter and an invisible field, but I would rather not clutter the form with invisible fields if they are not neccessary, and again I would like to avoid moving to that record through the use of a filter.

    Perhaps I wasn't clear enough about the problem the first time around. Maybe this clarifies it?
    Any other ideas?

    Thanks again,
    Tom

  4. #4
    Join Date
    May 2002
    Location
    Atlanta, GA
    Posts
    117
    Sorry about that.

    I set up a quick database with your idea in mind and got it to work. There are a few variations you can try but I think the easiest will be the following:

    Change your bound column on your List Box to 11 then use the following code.

    Private Sub cmdGotoRecord_Click()
    Dim varRecordNum
    If Not IsNull(Me.lstRecords) Then
    varRecordNum = Me.lstRecords
    DoCmd.OpenForm "frmEnrollmentRevisions"
    Forms!frmEnrollmentRevisions.RecordsetClone.FindFi rst "[RecordNum] = " & varRecordNum
    Forms!frmEnrollmentRevisions.Bookmark = Forms!frmEnrollmentRevisions.RecordsetClone.Bookma rk
    DoCmd.Close acForm, "frmRequestRecordSelector"
    End If

    If you have problems let me know.

    Kal
    End Sub

Posting Permissions

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