How to refresh subform which is created

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • Hemant Pandya
    New Member
    • Dec 2010
    • 1

    #1

    How to refresh subform which is created

    Hi
    I have a form (Product_Search ) & a sub form (PrdSerList) on it and after selecting value in combo box & after click search btn sub form does not refresh but when I reload the form it reload the result from previous SQL (dynamic) Query
    ***Code what I tried.
    Private Sub Btn_search_Clic k()
    Dim Prd_Name As String
    Dim ac_type As String
    Dim sql_str As String
    Dim db As DAO.Database
    Dim r_set As Recordset
    Dim qDef As DAO.QueryDef
    ' Dim TestQuery As String
    Dim xx As String
    Set db = CurrentDb
    Set qDef = db.QueryDefs("T estQuery") 'CreateQueryDef ("TestQuery" )

    Prd_Name = Me.Product_List
    ac_type = Me.Conect_lst

    ' MsgBox (Prd_Name & " " & ac_type)

    sql_str = "SELECT product,cif_cod e,account_no,ac count_type,conn ector FROM cif_dds_sy90 WHERE product = '" & _
    Prd_Name & "' AND connector = '" & ac_type & "' ORDER By CIF_CODE;"

    ' Debug.Print sql_str
    ' Set r_set = db.OpenRecordse t(sql_str)

    ' MsgBox (r_set.RecordCo unt)

    qDef.SQL = sql_str


    -- following 2 lines close and open Query Result
    ' DoCmd.Close acQuery, "TestQuery"
    ' DoCmd.OpenQuery "TestQuery" , acViewNormal, acReadOnly

    ---- tried followin to refrest not working

    ' Forms!Product_S earch.Requery
    ' Forms![Product_Search]![PrdSerList].Requery
    ' Forms!Product_S earch.PrdSerLis t.Recalc
    ' Forms!Product_S earch.PrdSerLis t.Form.Refresh
    ' Forms![Product_Search]![PrdSerList].Refresh
    ' Me.Requery
    ' DoCmd.Close acForm, Me.Name
    ' DoCmd.OpenForm ("TestQuery" )
    End Sub
  • orangeCat
    New Member
    • Dec 2007
    • 83

    #2
    Have you tried to Google for an answer?
    I found this link
    This MSAccess tutorial explains how to refresh the contents of a subform whenever the record in the parent form changes in Access 2003 (with screenshots and step-by-step instructions).

    Comment

    • malcolmk
      New Member
      • Sep 2010
      • 79

      #3
      build form prdserlist on the query then to refresh the form call it like this, Me.prdserlist.F orm.Requery
      Place this in your combobox update / change event or whatever.

      Comment

      Working...