运行时子表单列和数据更改不刷新表单
Subform column and data change at runtime not refreshing on Form
我有一个主窗体,其中有两个 Comobobx。
1. Type of Work (C_Art: Name of Combobox)
Repratur
Maintenance
Optimierung
2. Year (C_Year: Name of Combobox)
2018
2019
在主窗体上有一个完美工作的条形图和一个带有数据表视图的子窗体。
总体看起来像 。
我的问题是当我 select 2019 年子表单视图新 header 2019-Jan 2019-Feb ......2019-Dec 没有更新和行给我错误 #Name?
图表生成正确,没有任何问题。
我正在按如下方式在运行时更改查询。
Dim count_Status As String
Dim G_Stoerung As String
'Change the query for Graph
count_Status = "TRANSFORM Count(History_query.[LFD_NR]) AS CountOfLFD_NR " & _
" SELECT History_query.[Anlage] " & _
" FROM History_query " & _
" WHERE History_query.[Anlage] <>Null AND History_query.[WAS]= '" & Me.C_Art & "' AND History_query.[Year]= '" & Me.C_Year & "' " & _
" GROUP BY History_query.[Anlage] " & _
" PIVOT History_query.[Status] "
CurrentDb.QueryDefs("Count_Status_Anlage").sql = count_Status
'Updating the Graph with a new Data
Me.Graph9.Requery
Me!Graph9.ChartTitle.Text = Me.C_Art
'Chnage the query of subform
G_Stoerung = "TRANSFORM Count([History_query].WAS) AS CountOfWAS " & _
" SELECT [History_query].Status " & _
" FROM History_query " & _
" WHERE ((([History_query].WAS)= '" & Me.C_Art & "' ) AND [History_query].Status IN ('Offen','beobachten','In bearbeitung','erledigt') ) " & _
" GROUP BY Status " & _
" Order by (IIf([Status]='Offen',1,IIf([Status]='beobachten',2,IIf([Status]='In bearbeitung',3,IIf([Status]='erledigt',4))))) " & _
" PIVOT Format([Datum],'yyyy-mmm') IN ('" & Me.C_Year & "-Jan','" & Me.C_Year & "-Feb','" & Me.C_Year & "-Mar','" & Me.C_Year & "-Apr','" & Me.C_Year & "-May','" & Me.C_Year & "-Jun','" & Me.C_Year & "-Jul','" & Me.C_Year & "-Aug','" & Me.C_Year & "-Sep','" & Me.C_Year & "-Oct','" & Me.C_Year & "-Nov','" & Me.C_Year & "-Dec') "
CurrentDb.QueryDefs("G_Stoerung_query").sql = G_Stoerung
'Updating the subform with new Data
Me.G_Stoerung_Sub.Form.RecordSource = G_Stoerung
Me.G_Stoerung_Sub.Form.Requery
#NAME?错误将是因为文本框不再绑定到存在的字段。使字段名称通用并为年份应用过滤器参数。或者将子表单容器 SourceObject 属性 设置为查询对象而不是表单
编辑
G_Stoerung_Sub.SourceObject = ""
G_Stoerung_Sub.SourceObject = "Query.G_Stoerung_query"
更新源对象给出了期望的结果。
我有一个主窗体,其中有两个 Comobobx。
1. Type of Work (C_Art: Name of Combobox)
Repratur
Maintenance
Optimierung
2. Year (C_Year: Name of Combobox)
2018
2019
在主窗体上有一个完美工作的条形图和一个带有数据表视图的子窗体。
总体看起来像
我的问题是当我 select 2019 年子表单视图新 header 2019-Jan 2019-Feb ......2019-Dec 没有更新和行给我错误 #Name?
图表生成正确,没有任何问题。
我正在按如下方式在运行时更改查询。
Dim count_Status As String
Dim G_Stoerung As String
'Change the query for Graph
count_Status = "TRANSFORM Count(History_query.[LFD_NR]) AS CountOfLFD_NR " & _
" SELECT History_query.[Anlage] " & _
" FROM History_query " & _
" WHERE History_query.[Anlage] <>Null AND History_query.[WAS]= '" & Me.C_Art & "' AND History_query.[Year]= '" & Me.C_Year & "' " & _
" GROUP BY History_query.[Anlage] " & _
" PIVOT History_query.[Status] "
CurrentDb.QueryDefs("Count_Status_Anlage").sql = count_Status
'Updating the Graph with a new Data
Me.Graph9.Requery
Me!Graph9.ChartTitle.Text = Me.C_Art
'Chnage the query of subform
G_Stoerung = "TRANSFORM Count([History_query].WAS) AS CountOfWAS " & _
" SELECT [History_query].Status " & _
" FROM History_query " & _
" WHERE ((([History_query].WAS)= '" & Me.C_Art & "' ) AND [History_query].Status IN ('Offen','beobachten','In bearbeitung','erledigt') ) " & _
" GROUP BY Status " & _
" Order by (IIf([Status]='Offen',1,IIf([Status]='beobachten',2,IIf([Status]='In bearbeitung',3,IIf([Status]='erledigt',4))))) " & _
" PIVOT Format([Datum],'yyyy-mmm') IN ('" & Me.C_Year & "-Jan','" & Me.C_Year & "-Feb','" & Me.C_Year & "-Mar','" & Me.C_Year & "-Apr','" & Me.C_Year & "-May','" & Me.C_Year & "-Jun','" & Me.C_Year & "-Jul','" & Me.C_Year & "-Aug','" & Me.C_Year & "-Sep','" & Me.C_Year & "-Oct','" & Me.C_Year & "-Nov','" & Me.C_Year & "-Dec') "
CurrentDb.QueryDefs("G_Stoerung_query").sql = G_Stoerung
'Updating the subform with new Data
Me.G_Stoerung_Sub.Form.RecordSource = G_Stoerung
Me.G_Stoerung_Sub.Form.Requery
#NAME?错误将是因为文本框不再绑定到存在的字段。使字段名称通用并为年份应用过滤器参数。或者将子表单容器 SourceObject 属性 设置为查询对象而不是表单
编辑
G_Stoerung_Sub.SourceObject = ""
G_Stoerung_Sub.SourceObject = "Query.G_Stoerung_query"
更新源对象给出了期望的结果。