jebushatescats
IS-IT--Management
Hello all I hope I can explain by problem well enough for you all to understand what is going on.
I have a form with a sub form, normally this form upens up with the sub form getting its data from a query.
There are times when I need to open the form and then teh sub form using a different set of crieria for the sub form.
When I execute the code below(for the first time) the sub form will open with data that is not properly filtered. IF I close the form and imdediatly execute the same code the sub form will contain the correct data. Can anyone explain what I am doing wrong regarding the requery command?
sSQlName = "SELECT * FROM qryResponse WHERE
qryResponse.Person = " & "'" &
sUserName & "'" & ";" ' w9734
'build criteria link and open elements form
stDocName = "frmElement"
stLinkCriteria = "[EFG_ElementType]=" & "'" &
sElementType & "'" & " and " &
"[DocId]in(" & sDocId & ")" & ""
DoCmd.OpenForm stDocName, , , stLinkCriteria
' refresh responses sub form on elements form
Set dbs = CurrentDb
Set qdf = dbs.CreateQueryDef("", sSQlName)
Set rs1 = qdf.OpenRecordset(dbOpenDynaset)
Form_frmElement.sfResponseSubForm.Form.RecordSource = sSQlName
Form_frmElement.sfResponseSubForm.Requery
thanks!!
I have a form with a sub form, normally this form upens up with the sub form getting its data from a query.
There are times when I need to open the form and then teh sub form using a different set of crieria for the sub form.
When I execute the code below(for the first time) the sub form will open with data that is not properly filtered. IF I close the form and imdediatly execute the same code the sub form will contain the correct data. Can anyone explain what I am doing wrong regarding the requery command?
sSQlName = "SELECT * FROM qryResponse WHERE
qryResponse.Person = " & "'" &
sUserName & "'" & ";" ' w9734
'build criteria link and open elements form
stDocName = "frmElement"
stLinkCriteria = "[EFG_ElementType]=" & "'" &
sElementType & "'" & " and " &
"[DocId]in(" & sDocId & ")" & ""
DoCmd.OpenForm stDocName, , , stLinkCriteria
' refresh responses sub form on elements form
Set dbs = CurrentDb
Set qdf = dbs.CreateQueryDef("", sSQlName)
Set rs1 = qdf.OpenRecordset(dbOpenDynaset)
Form_frmElement.sfResponseSubForm.Form.RecordSource = sSQlName
Form_frmElement.sfResponseSubForm.Requery
thanks!!