Results 1 to 4 of 4

Thread: Subform problem

  1. #1
    Join Date
    Jun 2004
    Posts
    55

    Unanswered: Subform problem

    I have a form (SearchForm) with a subform (Searchsub) in it. The form is basically used to filter the records in a table via a query. The subform is meant to show the filtered records after the "Search" button clicked on the form.

    I've looked through the forum to get an answer on how to refresh the subform, but the solution are not working for me, unless I'm doing something wrong. I've tried the following:

    Me.Searchsub.Form.Requery
    Me.Searchsub.Form.Refresh
    Searchsub.Form.Requery
    Searchsub.Form.Refresh

    Can anyone help?

  2. #2
    Join Date
    Dec 2002
    Location
    Préverenges, Switzerland
    Posts
    3,740
    Me!SubFormName.Requery

    also check you have the correct name for the subform object: open the main form in design view, open the properties window, click once on the subform area and see properties/other/name ...it may not be the same as the saved .SourceObject form that you are using as your subform

    izy
    currently using SS 2008R2

  3. #3
    Join Date
    Jun 2004
    Posts
    55
    Yeah I had the ControlName and the subform name set to be the same and it has not worked thus far. I tried what you suggested and that didn't work, unfortunately. Thanks for the try though

    In case it may help here is the code I'm trying to use:
    Private Sub Search_Click()
    Dim Counter As String, qry As QueryDef, SQL As String, sqlWhere As String


    Counter = 0
    SQL = "SELECT [Master Table].[Fortune 1000 Rank], [Master Table].[Forbes 2000 Rank], [Master Table].[Company Name], [Master Table].Country, [Master Table].[Industry Type], [Master Table].[Revenue ($Bil)], [Master Table].[Profit ($Bil)]" & _
    " FROM [Master Table]"
    Set qry = CurrentDb.QueryDefs("qrySearchform")

    If IsNull([Company]) Then
    Else
    sqlWhere = "WHERE ((([Master Table].[Company Name]) Like '" & "*" & [Company] & "*')"
    End If

    SQL = SQL & _
    sqlWhere & ");"

    qry.SQL = SQL
    Me.frmSearchsub.Form.Requery
    End Sub
    Last edited by dwil2g1; 06-10-04 at 16:42.

  4. #4
    Join Date
    Jun 2004
    Posts
    55
    Okay...I found the answer! It was:

    Me.(MySubform).Form.RecordSource = "MyQuery"

    Where "MySubform" is the Subform Control name and "MyQuery" is the name of the query the subform is bounded too.

Posting Permissions

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