Results 1 to 3 of 3
  1. #1
    4 Star Lounger
    Join Date
    Dec 2002
    Location
    Kitchener, Ontario, Canada
    Posts
    421
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Syntax to Requery a form (2000 SP3)

    I have an unbound form Group Management which has three tabs on it holding other forms used to accomplish various tasks: Tab 1 - Printing reports; Tab 2 Adding people to various groups (frmMembershipGroups with a subform sbfrmMembershipGroups); Tab 3 - editing, adding and deleting group definitions(frmCommittee/GroupDefinitions).

    Tab 2 and 3 each have a combo box used to lookup records on that form, Combo 7 & 8. If I delete a group out of the frmCommittee/GroupDefinitions, how can I get frmMembershipGroups and the two combo boxes to requery and update themselves?

    I tried using the requery method following the syntax in VBA help and I just get #Deleted showing up.
    Here is the code I used on the from frmCommittee/GroupDefinition

    Private Sub Form_AfterUpdate()
    Dim Rst As Recordset
    Dim ctl1 As Control
    Dim ctl2 As Control
    ' Return Control object pointing to list box.
    Set Rst = Queries!qrycommittee
    ctl1 = Forms![frmGroup Management]![frmCommittee/GroupDefinition]!Combo7
    ctl2 = Forms![frmGroup Management]!frmMembershipGroups!Combo8
    ' Requery source of data for list box.
    Rst.Requery
    ctl1.Requery
    ctl2.Requery
    End Sub

    Peter

  2. #2
    Plutonium Lounger
    Join Date
    Mar 2002
    Posts
    84,353
    Thanks
    0
    Thanked 29 Times in 29 Posts

    Re: Syntax to Requery a form (2000 SP3)

    You can't set a recordset to a query, and I don't know why you would want to requery a stored query.

    If I understand you correctly, frmGroup Management is the main form. If so, you don't have to refer to controls on it with Forms![frmGroup Management]!..., you can use Me!... instead.

    If you want to requery a subform, you must specify it like this:

    Me.frmMembershipGroups.Form.Requery

    To requery a combo box on a subform, use an instruction like this:

    Me.frmMembershipGroups.Form.Combo8.Requery.

    See Refer to Form and Subform properties and controls on the Access web for a comprehensive overview.

  3. #3
    4 Star Lounger
    Join Date
    Dec 2002
    Location
    Kitchener, Ontario, Canada
    Posts
    421
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Syntax to Requery a form (2000 SP3)

    Thanks for the reference to the table on The Access Web. It took a couple of tries and a bit of logic, but I got things working properly. Ironically, I had downloaded the form on my home computer in the summer because I thought it would be useful <img src=/S/woops.gif border=0 alt=woops width=58 height=36> and forgot about it! I now have it at work as well.

    Peter

Posting Permissions

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