MS Access子窗体不显示记录和不导航(MS Access subform not displaying records and not navigating)

编程入门 行业动态 更新时间:2024-10-28 18:36:08
MS Access子窗体不显示记录和不导航(MS Access subform not displaying records and not navigating)

我在SLD表和ORDER表之间有一对一的关系。 SLD表是主窗体,ORDER表是子窗体。 主窗体的表具有比子窗体表更多的记录。 主链接和子链接已设置。 我已反编译并完成了紧凑和修复。 我怀疑我的应用程序出现故障。 在这种情况下,这不是第一次(我之前已经修复过)。 这一次似乎没有任何工作。 我也已经导入到一个新的数据库中。

在表单加载这两种形式和领域工作正常。 我使用['NEXT']按钮继续下一个记录,并到达子表单记录的末尾,因此具有空白字段。 我尝试导航到以前的记录(也使用按钮),但子窗体不移动/导航。 子表单没有任何反应。

看起来它变得更糟,因为它首先是导航,但它没有遵从代码说当文本框被填充禁用复选框,反之亦然。

I have a one-to-one relationship between an SLD table and an ORDER table. The SLD table is the main form, ORDER table is the subform. The main form's table has more records than the subform table. Master and child links are set. I have decompiled and have done compact and repair. I suspect my application is malfunctioning. In that case it is not the first time (I have fixed it before). Nothing seems to be working this time. I have also imported into a new database.

On form-load both forms and fields are working fine. I continue to the next records using a ['NEXT'] button and reach the end of the sub-forms records therefore having blanks fields. I try to navigate to the previous records (also using a button) but the subform does not move/navigate. Nothing happens to the subform.

It seems like it has gotten worse because first it was navigating but it was not obeying code saying when text box is filled disable checkbox and vise versa.

最满意答案

从它的声音中,问题出在你的Next按钮上,而不是它是一个子窗体问题。 正如您在评论中所述,默认导航允许表单按预期工作。

您的上一个按钮OnClick事件中是否存在此逻辑? 为了安全起见,我还要在下面的代码中添加OR语句,以确保它的捕获空值或空格

If (IsNull(Forms!Order!OrderSubform.Form!txtDate_Of_Order.Value‌​)) OR Forms!Order!OrderSubform.Form!txtDate_Of_Order.Value‌​ <> "" Then Forms!Order!OrderSubform.Form!txtDate_Of_Order.Enabled = False Forms!Order!OrderSubform.Form!chkbxOrder_Cancelled.Enabled = True Forms!Order!OrderSubform.Form!chkbxOrder_Cancelled.Value = True Else Forms!Order!OrderSubform.Form!txtDate_Of_Order.Enabled = True Forms!Order!OrderSubform.Form!chkbxOrder_Cancelled.Enabled = False Forms!Order!OrderSubform.Form!chkbxOrder_Cancelled.Value = False End If

I found out that the If statement belonged in Form_Current event. I am not experiencing the problem anymore after this code:

Private Sub Form_Current() If (IsNull(Forms!Order!OrderSubform.Form!txtOrder_Number.Value) Or _ Forms!Order!OrderSubform.Form!txtOrder_Number.Value = "") Then Forms!Order!OrderSubform.Form!txtDate_Of_Order.Enabled = True Forms!Order!OrderSubform.Form!chkbxOrder_Cancelled.Enabled = True ElseIf (IsNull(Forms!Order!OrderSubform.Form!txtDate_Of_Order.Value) Or _ Forms!Order!OrderSubform.Form!txtDate_Of_Order.Value = "") Then Forms!Order!OrderSubform.Form!txtDate_Of_Order.Enabled = False Forms!Order!OrderSubform.Form!chkbxOrder_Cancelled.Enabled = True Forms!Order!OrderSubform.Form!chkbxOrder_Cancelled.Value = True Else Forms!Order!OrderSubform.Form!txtDate_Of_Order.Enabled = True Forms!Order!OrderSubform.Form!chkbxOrder_Cancelled.Enabled = False Forms!Order!OrderSubform.Form!chkbxOrder_Cancelled.Value = False End If End Sub

更多推荐

本文发布于:2023-07-30 02:04:00,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1321644.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:窗体   Access   MS   subform   navigating

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!