Subform requery problem

kadams0920

Registered User.
Local time
Today, 16:50
Joined
Mar 14, 2007
Messages
20
I can't get the subform requery to work after making a selection from a combo box from the main form. Note the attached after update event code. I don't think the statement Me!fra_sbfrm_ClientSearch.Requery is working. Any suggestions? Thanks.

Dim qryT As DAO.queryDef
Dim duz
Dim SQLR As String

DoCmd.SetWarnings False
DoCmd.CopyObject , "qryClientSearch_Listbox", acQuery, "qryClientSearch_Listbox_Temp"
DoCmd.SetWarnings True
Me!fra_sbfrm_ClientSearch.Requery
Set qryT = CurrentDb.QueryDefs("qryClientSearch_Listbox")
duz = Len(qryT.SQL)
qryT.SQL = Left$(qryT.SQL, (duz - 3))
MsgBox qryT.SQL
SQLR = " WHERE Data_Outreach_Clients.Address= '"
SQLR = SQLR & Me!cboAddress.Value & "'" & " ORDER BY Data_Outreach_Clients.Last;"
MsgBox qryT.SQL & SQLR
qryT.SQL = qryT.SQL & SQLR
Me!fra_sbfrm_ClientSearch.Requery
Set qryT = Nothing
'DoCmd.OpenQuery "qryClientSearch_Listbox"
Exit Sub
 
Hello and Welcome!

If "fra_sbfrm_ClientSearch" is actually a subform control on your main form, then try:

Me!fra_sbfrm_ClientSearch.Form.Requery

HTH,
John
 
And a visual just to go with John's code (what is meant by subform control):

subformcontrol.png
 
Thanks guys. I modified the code to reflect the first response, and then checked to see if I'm using the control name and not the subform name, and that is what I'm doing, but it's still not working. Any other suggestion? I appreciate your help.

Karyn
 
Hi Karyn,

I think if you put:
qryT.Close
Before your Requery, then the changes you've made to the query will be saved, and the Requery will run accordingly.

HTH,
John
 

Users who are viewing this thread

Back
Top Bottom