重写子报表数据源时链接主报表和子报表(Linking master report and subreport when rewriting the subreport datasource)
我有一组'Master'表(TableA,TableB,TableC),每个表可以通过连接表(jctTableAX,jctTableAY,每个可选地链接(多对多)到一组'Linked'表(TableX,TableY,TableZ), jctTableAZ等)
表中的每个项目都有一个唯一的(长)标识符(例如Aid,Xid),用于构建链接,以及一个显示给用户的唯一(字符串)选择器(例如,ASelector,XSelector)。
每个主表或链接表都有一个关联的查询(例如qryA,qryX),它可以提取所有表数据并通过Selector对其进行排序。
我想制作一套报告,显示“主”表(A / B / C)中每个项目的完整细节; 每个报告都有一组三个子报告,显示链接选择器的列表。
(实际上有十几个主表和十几个链表,有些表可以是主表或链表,具体取决于上下文,所以我需要一个通用的可扩展解决方案 - 任何报告中都会有大多数子报表但是,因为并非每个表链接组合都受支持。)
我当前的设计包含每个主表的报告,以及每个链表的单个子报告。 这些子报表包含在每个主报表中,子报表的数据源将在子报表Open事件中重写(示例是针对X类型的链接项的子报表)
Dim strMasterType As String Dim strJunctionTable As String Static intCallCount As Long If intCallCount = 0 Then 'Only execute this once strMasterType = FormItemType(CurrentMasterForm) 'returns A B or C strJunctionTable = GetJunctionTable(strMasterType, "X") 'returns the relevant junction table name Me.RecordSource = "SELECT " & strJunctionTable & ".*, qryX.*, " & strJunctionTable & "." & strMasterType & "id AS MasterID FROM " & strJunctionTable & " LEFT JOIN qryX ON " & strJunctionTable & ".Xid = qryX.Xid;" End If intCallCount = intCallCount + 1
Link Master Field是Aid。 链接子字段是MasterID(这些是在报表设计时设置的,但我相信这应该让我重写不同主报表的子报表源,只要子报表源始终包含MasterID字段。)
- 这个设计是否合理还是有更好的解决方法?
- 在链接主字段/链接子字段设置或RecordSource SQL中有一些错误,因为我在子报表中获取相同的数据,即使主项目之间的链接数据不同,但我要进行代码盲测试把它整理出来。
I have a set of 'Master' tables (TableA, TableB, TableC) which can each optionally be linked (many to many) to a set of 'Linked' tables (TableX, TableY, TableZ) via junction tables (jctTableAX, jctTableAY, jctTableAZ etc.)
Each item in a table has a unique (Long) identifier (e.g. Aid, Xid) which are used to construct the links and a unique (string) Selector (e.g. ASelector, XSelector) that is displayed to the user.
Each master or linked table has an associated query (e.g. qryA, qryX) that pulls out all the table data and sorts it by Selector.
I want to produce a set of reports showing the full detail for each item from a 'Master' table (A/B/C); each report will have a set of three subreports showing lists of the linked selectors.
(In practice there are a dozen master tables, and a dozen linked tables, and some tables can be either master tables or linked tables depending on the context, so I need a generic scaleable solution -- the most subreports there will be in any report is 4 however, as not every combination of table links is supported.)
My current design has a report for each Master table, and a single subreport for each linked table. These subreports are included in each of the master reports, and the data source for the subreport is rewritten in the subrreport Open event thus (example is for subreport for linked items of type X)
Dim strMasterType As String Dim strJunctionTable As String Static intCallCount As Long If intCallCount = 0 Then 'Only execute this once strMasterType = FormItemType(CurrentMasterForm) 'returns A B or C strJunctionTable = GetJunctionTable(strMasterType, "X") 'returns the relevant junction table name Me.RecordSource = "SELECT " & strJunctionTable & ".*, qryX.*, " & strJunctionTable & "." & strMasterType & "id AS MasterID FROM " & strJunctionTable & " LEFT JOIN qryX ON " & strJunctionTable & ".Xid = qryX.Xid;" End If intCallCount = intCallCount + 1
Link Master Field is Aid. Link Child Field is MasterID (These are set at report design time, but I believe this should let me rewrite the subreport source for different master reports as long as the subreport source always has in it a MasterID field.)
- Is this design sensible or is there a better approach to the problem?
- There's something wrong either in the Link Master Field/Link Child Field set-up or the RecordSource SQL as I'm getting the same data in the subreports even though linked data differs between the master items, but I'm going code-blind trying to sort it out.
原文:https://stackoverflow.com/questions/37052190
最满意答案
你的方法看起来应该可以工作,但传入n作为参数会使其变脆,使用输入数组的长度字段会更好,甚至可以用这种方式处理锯齿状数组。
制作一份内容的副本不是必需的,因为字符串不能改变 - 这导致了一个主要问题:你做了什么样的改变,似乎反映在副本中? 向我们展示执行此操作的代码。
Your method looks like it should work, though passing in n as a parameter makes it brittle, using the input array's length field would be better, and you could even handle jagged arrays that way.
Making a copy of the contents is not necessary, since Strings cannot be changed - which leads to the main question: What kind of changes are you making that seem to be reflected in the copy? Show us the code that does this.
相关问答
更多-
一个问题是重新分配: str = realloc(str,str_num*sizeof(char)); 您只为单个字节分配空间,而不是指向char的指针。 这导致未定义的行为 。 改为例如 str = realloc(str,str_num*sizeof(char*)); 另一个问题,也是未定义行为的原因是实际的字符串分配: str[str_num-1] = realloc(str,strlen(str_new)); 在这里你重新分配str而不是str[0] 。 而且你没有为字符串终止符分配空间。 为 ...
-
不确定这个方法的效率,但是使用JSON.stingify()将数组转换为字符串然后通过JSON.parse()解析回原始格式会使对象失去其原始引用并且没有任何痛苦地工作。 var panel = new Array(3).fill(new Array(3).fill('*')); var copy = JSON.parse(JSON.stringify(panel)); copy[1][1] = '#'; //you can assign the value of variable 'copy ...
-
你的方法看起来应该可以工作,但传入n作为参数会使其变脆,使用输入数组的长度字段会更好,甚至可以用这种方式处理锯齿状数组。 制作一份内容的副本不是必需的,因为字符串不能改变 - 这导致了一个主要问题:你做了什么样的改变,似乎反映在副本中? 向我们展示执行此操作的代码。 Your method looks like it should work, though passing in n as a parameter makes it brittle, using the input array's length ...
-
复制2维数组(copy 2-dimensional Array)[2023-07-16]
def copy(bild: Array[Array[Int]]):Unit = { val result = Array.ofDim[Array[Int]](bild.length) for(x <- 0 until bild.length) { result(x) = Array.ofDim[Int](bild(x).length) for(y <- 0 until bild(x).length) { result(x)(y) = bild(x)(y) } ... -
我相信你在这里至少有一个问题: strncpy(Result, ix + (Offset - LEN),LEN); 如果您查看strncpy的文档 ,您将看到如果您按下字符数限制,它不会自动以空字符结尾复制的字符串。 因此,您的Result字符串不是空终止的。 尝试改变这一点: strncpy(Result, ix + (Offset - LEN),LEN); Result[LEN] = '\0'; 当然,您仍然需要为结果字符串提供内存。 目前,您正在将未初始化的指针传递给GetStr() : char ...
-
-split返回一个string[]类型的对象,这意味着除了字符串之外,不能将任何其他内容分配给单个项目,而不会更改整个数组的类型。 相反,当解析器发现你正试图将一个新数组分配给现有的$services字符串数组中的某个项时,它会自动将新数组转换为字符串,并由$OFS连接。 由于$OFS默认为一个空格,所以你必须转换这个字符串: SUPER-PC,Microsoft Office ClickToRun Service,ClickToRunSvc,C:\Program Files\Microsoft Offi ...
-
您可以将array.prototype.some与array.prototype.includes一起使用。 它应该是: var datas= [ ["aaa", "bbb"], ["ddd", "eee"] ]; function exists(arr, search) { return arr.some(row => row.includes(search)); } console.log(exists(datas, 'ddd')); console.log(ex ...
-
你实际上没有二维char数组。 相反,你有一个char指针的一维数组。 在二维char数组中,所有字符串将具有为它们分配的完全相同的内存量。 您的案例在很多方面实际上更简单。 编译器创建了一堆常量字符串,并使用这些指针初始化char *数组。 每个字符串都有自己独立的长度。 这是你如何声明一个真正的二维char数组: char states[][11] = { "California", "Oregon", "Washington", "Texas" }; 这里字符串长度是 ...
-
正则表达式将字符串匹配为二维整数数组(regular expression to match a string as a two dimensional array of integers)[2023-10-18]
您可以使用这种模式(如果需要,添加可选的CR): (?m)^(?>(?>\\d+([ \\t]|$)(?=.*\\n(\\2?+\\d+\\1)))+\\n(?=\\2$))+.* 演示 (单击java按钮) 对于第一行中的每个项目,前瞻检查下一行中是否存在同一列中的项目。 要知道列是否相同,捕获组2包含可选的自引用\\2?+ 。 以这种方式,每当“项目”组重复(并到达下一列)时,捕获组2就会增长。 细节: (?m) # use the multiline mode ^ # start of the ... -
我建议将String[][]改编为CharSequence 。 然后,您可以自由地使用CharSequence执行所有操作,这也意味着您可以使用java.util.regex.Matcher搜索字符串,而无需实现自己的搜索算法。 例如: public class Main { public static void main(String[] args) { String[][] array2d = createArray(); int charSeqColumn = ...