Results 1 to 3 of 3
  1. #1
    Join Date
    May 2002

    Unanswered: Data in controls and same data in Datasheet view also. Subform not updating. !! HLP !

    I am trying to figure out how to do this.

    I have a Form that has different controls i.e. TextBoxes, ComboBoxes, Labels etc and it is my Main Form also. The value in the controls are filled by running a Query and with NavigationButtons can Navigate through the data i.e. Record Source Property of my Main Form is a Query. Lets's say I get 15 records when the query returns a result and the first record is shown in the controls by default, to get to different record can use the NavigationButtons.

    Now what I also want is that to show the same result in a Dataseet view also so that the user can see all the records at one time also. So for this I have a subform whose Record Source Property is also set to the same Query that's set to Main Form. Now when my Form pops-up it shows all the records in a subform Datasheet and also the individual records in the controls of my Main Form and can use NavigationButtons to move to different record. On my my Main Form I also have a button that when clicked searches a table against any value the user selects in the Main Form control and returns the result e.g. it returns 5 records so my controls in my Main Form are updated and the NavigationButtons show 5 and can move arround. But my subform doesn't show those five records returned by search. How can I update my subform also.

    In my buttons clicked event I am using this to filter as I have disabled the Default Filter buttons of Access.

    DoCmd.RunCommand acCmdFilterBySelection

    to filter through the results. How can I show the filtered records in my subform also. Filtering is only done on the Main Form's controls and my subform is there only to show the results in a Datasheet view and I also don't show the NavigationButtons for the subform as it is a Datasheet with scrolls.

    I'll really appreciate for any help.

  2. #2
    Join Date
    May 2002
    Atlanta, GA
    Here is a thought,

    Instead of using a datasheet, use a list box. Set the row source of the list box the same as your record source on your form. Then use the On_Click event of the List box to find the record based on the control.

    In otherwords you would be able to scroll through your records with the navigation buttons on your main form but also have a list box of all the records. When you click on a record within the List Box your form would find that record that matches the List Box Control.

    Does this help?

  3. #3
    Join Date
    May 2002
    Atlanta, GA

    Here is some code that might help:

    The "On Error Resume Next" will help prevent errors if the List Box is empty.
    First Requery the ListBox everytime you click it so the data is accurate
    Then Match the List Box Control to the Recordset.

    Private Sub ListBox_On_Click()
    On Error Resume Next
    DoCmd.Requery "ListBox"

    Dim myrecordset As Object
    Set myrecordset = Me.Recordset.Clone
    rs.FindFirst "[YourField] = " & Str(Me![ListBox])
    Me.Bookmark = rs.Bookmark

    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