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
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
Comment