首页 \ 问答 \ 重写子报表数据源时链接主报表和子报表(Linking master report and subreport when rewriting the subreport datasource)

重写子报表数据源时链接主报表和子报表(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字段。)

  1. 这个设计是否合理还是有更好的解决方法?
  2. 在链接主字段/链接子字段设置或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.)

  1. Is this design sensible or is there a better approach to the problem?
  2. 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
更新时间:2022-02-12 12:02

最满意答案

你的方法看起来应该可以工作,但传入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 ...
  • 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" }; 这里字符串长度是 ...
  • 您可以使用这种模式(如果需要,添加可选的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 = ...

相关文章

更多

最新问答

更多
  • 您如何使用git diff文件,并将其应用于同一存储库的副本的本地分支?(How do you take a git diff file, and apply it to a local branch that is a copy of the same repository?)
  • 将长浮点值剪切为2个小数点并复制到字符数组(Cut Long Float Value to 2 decimal points and copy to Character Array)
  • OctoberCMS侧边栏不呈现(OctoberCMS Sidebar not rendering)
  • 页面加载后对象是否有资格进行垃圾回收?(Are objects eligible for garbage collection after the page loads?)
  • codeigniter中的语言不能按预期工作(language in codeigniter doesn' t work as expected)
  • 在计算机拍照在哪里进入
  • 使用cin.get()从c ++中的输入流中丢弃不需要的字符(Using cin.get() to discard unwanted characters from the input stream in c++)
  • No for循环将在for循环中运行。(No for loop will run inside for loop. Testing for primes)
  • 单页应用程序:页面重新加载(Single Page Application: page reload)
  • 在循环中选择具有相似模式的列名称(Selecting Column Name With Similar Pattern in a Loop)
  • System.StackOverflow错误(System.StackOverflow error)
  • KnockoutJS未在嵌套模板上应用beforeRemove和afterAdd(KnockoutJS not applying beforeRemove and afterAdd on nested templates)
  • 散列包括方法和/或嵌套属性(Hash include methods and/or nested attributes)
  • android - 如何避免使用Samsung RFS文件系统延迟/冻结?(android - how to avoid lag/freezes with Samsung RFS filesystem?)
  • TensorFlow:基于索引列表创建新张量(TensorFlow: Create a new tensor based on list of indices)
  • 企业安全培训的各项内容
  • 错误:RPC失败;(error: RPC failed; curl transfer closed with outstanding read data remaining)
  • C#类名中允许哪些字符?(What characters are allowed in C# class name?)
  • NumPy:将int64值存储在np.array中并使用dtype float64并将其转换回整数是否安全?(NumPy: Is it safe to store an int64 value in an np.array with dtype float64 and later convert it back to integer?)
  • 注销后如何隐藏导航portlet?(How to hide navigation portlet after logout?)
  • 将多个行和可变行移动到列(moving multiple and variable rows to columns)
  • 提交表单时忽略基础href,而不使用Javascript(ignore base href when submitting form, without using Javascript)
  • 对setOnInfoWindowClickListener的意图(Intent on setOnInfoWindowClickListener)
  • Angular $资源不会改变方法(Angular $resource doesn't change method)
  • 在Angular 5中不是一个函数(is not a function in Angular 5)
  • 如何配置Composite C1以将.m和桌面作为同一站点提供服务(How to configure Composite C1 to serve .m and desktop as the same site)
  • 不适用:悬停在悬停时:在元素之前[复制](Don't apply :hover when hovering on :before element [duplicate])
  • 常见的python rpc和cli接口(Common python rpc and cli interface)
  • Mysql DB单个字段匹配多个其他字段(Mysql DB single field matching to multiple other fields)
  • 产品页面上的Magento Up出售对齐问题(Magento Up sell alignment issue on the products page)