我有一个使用子表单访问的主表单(连续表单模式)。子表单的源是一个查询,它有一个criteria参数,可以从mainform中的组合框中获取值。
当我打开主窗体时,组合框是空的,子窗体显示所有记录。如果我在组合框中选择一个值并单击一个只有以下代码行的刷新按钮:me.subformname.form.requery
它工作正常,子窗体重新查询并刷新显示相应的记录。
如果我更改了组合框中的值并点击了刷新按钮,它再次重新查询/刷新子表单。
问题是,如果我使用上下文菜单(Right Click > "Equals to...")
过滤subfrom,则相应地过滤子表单,然后删除子表单未过滤的过滤器(Right Click > "Clear filter from...")
,但现在如果我更改了组合框值并点击刷新按钮,子窗体不刷新也不重新查询。
即使我在后台打开查询,也是如此。一旦我过滤,刷新就不再起作用了。
这是子表单查询:
SELECT qry_listatoatesesizarile.idsesizare,
branduri.numebrand,
locatii.fsname,
categoriiechipamente.categorieechipament,
echipamente.codechipament,
qry_listatoatesesizarile.nrsesizare,
qry_listatoatesesizarile.datasesizare,
qry_listatoatesesizarile.datasla,
qry_listatoatesesizarile.detalii,
qry_listatoatesesizarile.stare,
Dlookup("[stareraport]", "listastarirapoarte",
"[idstareraport]=" & [stare]) AS
StareS,
echipe.denumireechipa
AS EchipaLocatie,
qry_listarapoarte.nrraport,
qry_listarapoarte.datainceput,
qry_listarapoarte.datafinalizat,
qry_listarapoarte.lucrariefectuate,
qry_listarapoarte.cauzadefectiune,
qry_listasesizariprogramate.denumireechipa
AS EchipaProgramata,
Iif([stare] = 1
OR [stare] = 3
OR [stare] = 0, Datediff("s", Cdate([datasla]), Now()),
Datediff("s", Cdate([datasla]), Cdate([datafinalizat])))
AS DiferentaSLASecs,
Secs2dhms([diferentaslasecs])
AS DiferentaSLA,
Iif([diferentaslasecs] < 0, true, false)
AS InSLA,
Format([datasesizare], "mmmm yyyy")
AS [Month],
Iif([stare] = 2
OR [stare] = 4, Iif([diferentaslasecs] < 0, "inchis in sla",
"inchis in afara sla"),
Iif([diferentaslasecs] < 0, "deschis in sla", "deschis in afara sla"))
AS
Situatie,
locatii.clientfrigorifice,
clienti.client
FROM clienti
INNER JOIN (((((branduri
INNER JOIN ((qry_listatoatesesizarile
INNER JOIN echipamente
ON
qry_listatoatesesizarile.idechipament =
echipamente.idechipament)
INNER JOIN locatii
ON echipamente.idlocatie =
locatii.idlocatie)
ON branduri.idbrand = locatii.idbrand)
INNER JOIN categoriiechipamente
ON echipamente.idcategorieechipament =
categoriiechipamente.idcategorieechipament)
INNER JOIN echipe
ON qry_listatoatesesizarile.idechipa =
echipe.idechipa)
LEFT JOIN qry_listasesizariprogramate
ON qry_listatoatesesizarile.idsesizare =
qry_listasesizariprogramate.idsesizare)
LEFT JOIN qry_listarapoarte
ON qry_listatoatesesizarile.idraport =
qry_listarapoarte.idraport)
ON clienti.idclient = locatii.clientfrigorifice
WHERE ( ( ( Format([datasesizare], "mmmm yyyy") ) LIKE Iif(Nz(
[forms] ! [controlsla] ! [cb_lunaverificata], "") = "", "*",
[forms] ! [controlsla] ! [cb_lunaverificata]) )
AND ( ( locatii.clientfrigorifice ) LIKE Iif(Nz(
[forms] ! [controlsla] ! [cb_client]
,
"") = "", "*",
[forms] ! [controlsla] ! [cb_client]) ) );
答案 0 :(得分:3)
访问可能有点过滤,特别是在子表单上。
尝试在Combobox代码中添加显式代码,以便每次都清除过滤器。所以它看起来像:
Me.subformname.Form.Filter = Null
Me.subformname.Form.FilterOn = False
Me.subformname.Form.Requery
或者,您可以尝试在Combobox中的每次更改时动态重置子窗体的RecordSource。 (注意,如果你这样做,你不必显式重新查询,因为它是自动完成的。)因此,现在代替你在Combobox中的代码,你有以下几点:
Dim mySQLString as String
'Store subform query
mySQLString = "SELECT qry_listato... <<The rest of your query here>>>"
'Set Subform RecordSource
Me.subformname.Form.RecordSource = mySQLSTring
希望其中一个可以帮助你。