Results 1 to 2 of 2
  1. #1
    Join Date
    Jan 2003

    Exclamation Unanswered: want a code to open selected recordset


    i need a code to open only the user specified records from the recordset
    ie if a record contain some 50 records and i want to select only the records from 10 to 18 .
    how can i do this
    someone write me the code with example

  2. #2
    Join Date
    Jan 2003
    Aberdeen, Scotland, UK

    Thumbs up Re: want a code to open selected recordset

    If, for example, you wanted the user to specify the records from, say, a list box, you could put this in the afterupdate of the listbox.

    Private Sub RecordList_AfterUpdate()
    ' Print the list of selected items to the text
    ' box txtSelected.
    Dim varItem As Variant
    Dim StrList As String
    Dim Db as Database
    Dim Rs as Recordset
    Set Db = Currentdb()

    ' Here's the code for selecting the records
    With Me.RecordList
    If .MultiSelect = 0 Then
    Me!txtselected = .Value
    For Each varItem In .ItemsSelected
    StrList = StrList & .Column(0, varItem) & " or [recordID] = "
    Next varItem
    End If
    End With
    'Open the recordset
    set rs = db.openrecordset("select * from [yourtable] where " & StrList)
    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