Do datasheets support multiple selections?

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • deko

    Do datasheets support multiple selections?

    How do I get the items selected from a datasheet? Does a datasheet support
    multiple selections?

    I know a ListBox has a "Selected" property that can be used when the
    MultiSelect property is set - but is there a way to get the same
    functionality with a datasheet?

    If not, I'm throwing all my datasheets in the junk..... why bother with
    datasheets? get all the same functionality with a listbox?

    For example, with a ListBox, it might look something like this;

    Dim varItem As Variant

    Dim ctl As Control

    Set ctl = frmMain!lstName s

    For Each varItm In ctl.ItemsSelect ed

    Debug.Print ctl.ItemData(va rItm)

    Next varItm

    With a datasheet:

    Dim ctl As Control
    Set ctl = Forms!frmMain!f rmInventory
    For Each varItem In ctl.ItemData(va rItem)
    Debug.Print varItem
    Next

    does not work


    Dim frm As Form
    Set frm = Forms!frmMain!f rmInventory.For m
    For Each varItem in frm.?????
    Debug.Print varItem
    Next


  • Allen Browne

    #2
    Re: Do datasheets support multiple selections?

    You can select contiguous rows in a datasheet.

    Use the SelTop and SelHeight properties to get information about the
    selected rows programmaticall y.

    --
    Allen Browne - Microsoft MVP. Perth, Western Australia.
    Tips for Access users - http://allenbrowne.com/tips.html
    Reply to group, rather than allenbrowne at mvps dot org.

    "deko" <dje422@hotmail .com> wrote in message
    news:G_aNb.1034 8$B7.6735@newss vr25.news.prodi gy.com...[color=blue]
    > How do I get the items selected from a datasheet? Does a datasheet[/color]
    support[color=blue]
    > multiple selections?
    >
    > I know a ListBox has a "Selected" property that can be used when the
    > MultiSelect property is set - but is there a way to get the same
    > functionality with a datasheet?
    >
    > If not, I'm throwing all my datasheets in the junk..... why bother with
    > datasheets? get all the same functionality with a listbox?
    >
    > For example, with a ListBox, it might look something like this;
    >
    > Dim varItem As Variant
    >
    > Dim ctl As Control
    >
    > Set ctl = frmMain!lstName s
    >
    > For Each varItm In ctl.ItemsSelect ed
    >
    > Debug.Print ctl.ItemData(va rItm)
    >
    > Next varItm
    >
    > With a datasheet:
    >
    > Dim ctl As Control
    > Set ctl = Forms!frmMain!f rmInventory
    > For Each varItem In ctl.ItemData(va rItem)
    > Debug.Print varItem
    > Next
    >
    > does not work
    >
    >
    > Dim frm As Form
    > Set frm = Forms!frmMain!f rmInventory.For m
    > For Each varItem in frm.?????
    > Debug.Print varItem
    > Next
    >
    >[/color]


    Comment

    • Mike Storr

      #3
      Re: Do datasheets support multiple selections?

      You can access the rowindex by checking the SelTop and SelHeight properties
      of the form to determine the starting row number, and the number of rows
      selected.

      Mike Storr



      "deko" <dje422@hotmail .com> wrote in message
      news:G_aNb.1034 8$B7.6735@newss vr25.news.prodi gy.com...[color=blue]
      > How do I get the items selected from a datasheet? Does a datasheet[/color]
      support[color=blue]
      > multiple selections?
      >
      > I know a ListBox has a "Selected" property that can be used when the
      > MultiSelect property is set - but is there a way to get the same
      > functionality with a datasheet?
      >
      > If not, I'm throwing all my datasheets in the junk..... why bother with
      > datasheets? get all the same functionality with a listbox?
      >
      > For example, with a ListBox, it might look something like this;
      >
      > Dim varItem As Variant
      >
      > Dim ctl As Control
      >
      > Set ctl = frmMain!lstName s
      >
      > For Each varItm In ctl.ItemsSelect ed
      >
      > Debug.Print ctl.ItemData(va rItm)
      >
      > Next varItm
      >
      > With a datasheet:
      >
      > Dim ctl As Control
      > Set ctl = Forms!frmMain!f rmInventory
      > For Each varItem In ctl.ItemData(va rItem)
      > Debug.Print varItem
      > Next
      >
      > does not work
      >
      >
      > Dim frm As Form
      > Set frm = Forms!frmMain!f rmInventory.For m
      > For Each varItem in frm.?????
      > Debug.Print varItem
      > Next
      >
      >[/color]


      Comment

      • deko

        #4
        Re: Do datasheets support multiple selections?

        > You can select contiguous rows in a datasheet.

        Thanks... but I'll have to admit - I'm beginning to like list boxes more...


        Comment

        • Allen Browne

          #5
          Re: Do datasheets support multiple selections?

          By all means use a list box if you only need to display a few rows (not 10s
          of thousands), and you do not need to edit the columns.

          They use fewer resources than subforms do.

          --
          Allen Browne - Microsoft MVP. Perth, Western Australia.
          Tips for Access users - http://allenbrowne.com/tips.html
          Reply to group, rather than allenbrowne at mvps dot org.

          "deko" <dje422@hotmail .com> wrote in message
          news:jRlNb.1075 $6u5.35@newssvr 29.news.prodigy .com...[color=blue][color=green]
          > > You can select contiguous rows in a datasheet.[/color]
          >
          > Thanks... but I'll have to admit - I'm beginning to like list boxes[/color]
          more...


          Comment

          • deko

            #6
            Re: Do datasheets support multiple selections?

            > By all means use a list box if you only need to display a few rows (not
            10s[color=blue]
            > of thousands), and you do not need to edit the columns[/color]

            Yes, I suppose that is one big advantage of a datasheet - in-cell editing;
            also, filtering. Is there a best-practices limit of how may records should
            be retreived with a listbox? several hundred? one thousand? By the way, I
            think the standard DataGrid in VB does support multiple selection, unlike
            the Access datasheet.



            Comment

            • deko

              #7
              Re: Do datasheets support multiple selections?

              While I have the opportunity to rant about the limitations of datasheets,
              let's not forget how difficult it is to work with column widths - for
              example, let's say I have a subform datasheet that I want to keep a certian
              size (height and width) on the main form - a vertical scrollbar appears as
              the number of records exceeds the available height. The problem is that
              this results in the unwelcome appearance of a horizontal scrollbar (even if
              the scrollbars property is set to vertical only) if the vertical scrollbar
              overlaps any text (in any of the existing rows) when it appears. Column
              widths are also a pain to set programatically .

              I feel better now....


              Comment

              • Lyle Fairfield

                #8
                Re: Do datasheets support multiple selections?

                "deko" <dje422@hotmail .com> wrote in
                news:oZpNb.1129 4$la3.5684@news svr27.news.prod igy.com:
                [color=blue]
                > Yes, I suppose that is one big advantage of a datasheet - in-cell
                > editing; also, filtering.[/color]

                I never knew that! Wow!

                --
                Lyle
                (for e-mail refer to http://ffdba.com/contacts.htm)

                Comment

                • Allen Browne

                  #9
                  Re: Do datasheets support multiple selections?

                  Deko, have you tried Continuous Form view instead of Datasheet?

                  Users cannot get stuck hiding columns etc.
                  Form header and footer sections are displayed, and can have command buttons.

                  Glad you feel better after the rant. :-)

                  --
                  Allen Browne - Microsoft MVP. Perth, Western Australia.
                  Tips for Access users - http://allenbrowne.com/tips.html
                  Reply to group, rather than allenbrowne at mvps dot org.

                  "deko" <dje422@hotmail .com> wrote in message
                  news:T9qNb.1129 5$Ki3.3859@news svr27.news.prod igy.com...[color=blue]
                  > While I have the opportunity to rant about the limitations of datasheets,
                  > let's not forget how difficult it is to work with column widths - for
                  > example, let's say I have a subform datasheet that I want to keep a[/color]
                  certian[color=blue]
                  > size (height and width) on the main form - a vertical scrollbar appears as
                  > the number of records exceeds the available height. The problem is that
                  > this results in the unwelcome appearance of a horizontal scrollbar (even[/color]
                  if[color=blue]
                  > the scrollbars property is set to vertical only) if the vertical scrollbar
                  > overlaps any text (in any of the existing rows) when it appears. Column
                  > widths are also a pain to set programatically .
                  >
                  > I feel better now....[/color]


                  Comment

                  Working...