Results 1 to 4 of 4
  1. #1
    Join Date
    Sep 2009
    Posts
    8

    Unanswered: Refresh a subform from a main form

    I have a form called recSignupComm with a list box and a subform called frmDistSubform. I want to update the subform each time a different item is selected in the list box.

    I have tried dozens of different combinations from different sites but they all seem to be throwing errors

    this is what I have at the moment:
    Private Sub List2_Click()
    Forms![frmrecsignupcomm].[frmdistsubform].Form.Requery
    End Sub

    the error I get is run-time error '2465': microsoft office access can't find the field '|' referred to in your expression
    Last edited by GinjaNinja; 05-11-11 at 21:29. Reason: added error message

  2. #2
    Join Date
    Mar 2009
    Posts
    5,442
    Provided Answers: 14
    1. For updating the subform each time a different item is selected in the list box you should use the AfterUpdate event of the ListBox, not the Click event.

    2. Me.frmdistsubform.Form.Requery works too and is shorter.

    3. What's the contents of the RecordSource and the Filter properties of the subform?
    Have a nice day!

  3. #3
    Join Date
    Sep 2009
    Posts
    8
    Quote Originally Posted by Sinndho View Post
    1. For updating the subform each time a different item is selected in the list box you should use the AfterUpdate event of the ListBox, not the Click event.

    2. Me.frmdistsubform.Form.Requery works too and is shorter.

    3. What's the contents of the RecordSource and the Filter properties of the subform?
    recordsource is Dist (table)
    filter is empty
    will afterupdate change the subform instantly? I want to show the distributors information as soon as their name is selected in the listbox

  4. #4
    Join Date
    Mar 2009
    Posts
    5,442
    Provided Answers: 14
    Quote Originally Posted by GinjaNinja View Post
    recordsource is Dist (table)
    filter is empty
    How do you link the contents of the SubForm to the value of the ListBox?
    Quote Originally Posted by GinjaNinja View Post
    will afterupdate change the subform instantly? I want to show the distributors information as soon as their name is selected in the listbox
    Yes, the AfterUpdate event occurs before the Click event. Here's the order of succession of events for a ListBox:
    Code:
    Event: Form_Current         Value: 3 <-- Original Value
    Event: Enter                Value: 3
    Event: GotFocus             Value: 3
    Event: MouseMove            Value: 3
    Event: MouseDown            Value: 3
    Event: MouseUp              Value: 3
    Event: BeforeUpdate         Value: 1 <-- Value changes here
    Event: AfterUpdate          Value: 1
    Event: Click                Value: 1
    Event: MouseMove            Value: 1
    Event: MouseUp              Value: 1
    Event: Exit                 Value: 1
    Event: LostFocus            Value: 1
    Have a nice day!

Posting Permissions

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