Results 1 to 9 of 9
  1. #1
    Silver Lounger
    Join Date
    Jun 2001
    Location
    Niagara Falls, New York, USA
    Posts
    1,878
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Open Datasheet Form to Selected Record? (a2k (9.0.6926) SP-3 Jet 4.0 SP-7)

    I have a button on a Single Form that when pressed displays all the underlying records in the table in a Datasheet Form.

    For example, say in Single Form, I
    Attached Files Attached Files

  2. #2
    Platinum Lounger
    Join Date
    Dec 2001
    Location
    Melbourne, Australia
    Posts
    4,594
    Thanks
    0
    Thanked 27 Times in 27 Posts

    Re: Open Datasheet Form to Selected Record? (a2k (9.0.6926) SP-3 Jet 4.0 S

    Both forms are based upon the Customers table, so I am confused as to what you are trying to achieve.

  3. #3
    Silver Lounger
    Join Date
    Jun 2001
    Location
    Niagara Falls, New York, USA
    Posts
    1,878
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Open Datasheet Form to Selected Record? (a2k (9.0.6926) SP-3 Jet 4.0 S

    Pat

    In the sample db, If I navigate through the records to the third record, when I click the Show All button it oens another form with all the records in datasheet view. In datasheet view I want the third record to be selected.

    Anys clues?

    Thanks, John

  4. #4
    Platinum Lounger
    Join Date
    Dec 2001
    Location
    Melbourne, Australia
    Posts
    4,594
    Thanks
    0
    Thanked 27 Times in 27 Posts

    Re: Open Datasheet Form to Selected Record? (a2k (9.0.6926) SP-3 Jet 4.0 S

    Why do you want just the 3rd record to be viewed when it is already viewed in the first form?

    If you want to do this just change the OpenReport command to:
    DoCmd.OpenForm strCustomersLookup, acFormDS, , "ID=" & ID, , , Me.Name

  5. #5
    Silver Lounger
    Join Date
    Jun 2001
    Location
    Niagara Falls, New York, USA
    Posts
    1,878
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Open Datasheet Form to Selected Record? (a2k (9.0.6926) SP-3 Jet 4.0 S

    Hi Pat

    In the sample db, If I navigate through the records to the third record for example, when I click the Show All button it opens another form with all the records in datasheet view.

    In datasheet view I want to see all the records and in this example the third record to be selected.

    Thanks, John

  6. #6
    Super Moderator
    Join Date
    Aug 2001
    Location
    Evergreen, CO, USA
    Posts
    6,623
    Thanks
    3
    Thanked 60 Times in 60 Posts

    Re: Open Datasheet Form to Selected Record? (a2k (9.0.6926) SP-3 Jet 4.0 S

    Hi John,
    What I think Pat is trying to ask is why in the world do you want to do this? At least I am - I understand what you are asking, but what sort of functional thing to you expect to accomplish by doing this? In general, we discourage people from looking at all records in a table, or we use a continuous form to show multiple records, as all sorts of things can go wrong when users have a table at their disposal to play with. In this case the user could click on any record they wanted to and make edits and so on.
    Wendell

  7. #7
    Silver Lounger
    Join Date
    Jun 2001
    Location
    Niagara Falls, New York, USA
    Posts
    1,878
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Open Datasheet Form to Selected Record? (a2k (9.0.6926) SP-3 Jet 4.0 S

    Hi Wendell

    I was just prototyping a new user interface for future record manipulation of records in a table

    This is just a concept not necessarily a complete application

    John

  8. #8
    Bronze Lounger
    Join Date
    Nov 2001
    Location
    Arlington, Virginia, USA
    Posts
    1,394
    Thanks
    0
    Thanked 3 Times in 3 Posts

    Re: Open Datasheet Form to Selected Record? (a2k (9.0.6926) SP-3 Jet 4.0 S

    I've done something like this in a Personnel database where user can open detail record (single-record form) from a datasheet form or subform, or vice versa. Generally the user cannot edit the datasheet records in this scenario, any edits must be done in the single-record form that has all the validation code, etc. The datasheet is used mainly as a quick navigation tool or to look up some info quickly. Anyway if interested see attached copy of modified sample db, same code is basically used for main form's Show All button and for datasheet form's Form_DblClick event, so you can do same thing in reverse - select record on datasheet then double-click to open main form (CustomersTest) and navigate to matching record. In latter case, changed only name of form, and did not specify datasheet view. Example code:

    Private Sub Show_All_Click()

    Dim rst As DAO.Recordset
    Dim frm As Form
    Dim strFrm As String
    Dim strCustID As String

    strCustID = Me.CustomerID
    strFrm = "Customers_LookupTest"

    DoCmd.OpenForm strFrm, acFormDS, , , , , Me.Name

    Set frm = Forms(strFrm)
    Set rst = frm.RecordsetClone
    rst.FindFirst "<!t>[CustomerID]<!/t> = '" & strCustID & "'"

    If Not rst.NoMatch Then
    With frm
    .Bookmark = rst.Bookmark
    .CompanyName.SetFocus
    End With
    Else
    MsgBox "Record not found.", vbExclamation, "NOT FOUND"
    End If

    Set rst = Nothing
    Set frm = Nothing

    End Sub

    Note that I added a reference to DAO 3.6 library in att'd db to be able to specify DAO recordset variable.

    HTH
    Attached Files Attached Files

  9. #9
    Silver Lounger
    Join Date
    Jun 2001
    Location
    Niagara Falls, New York, USA
    Posts
    1,878
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Open Datasheet Form to Selected Record? (a2k (9.0.6926) SP-3 Jet 4.0 S

    Thanks Mark

    Thats exactly what I was looking for.

    John

Posting Permissions

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