MS Access subform not displaying records and not navigating

夙愿已清 提交于 2019-12-12 06:15:07

问题


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.


回答1:


From the sounds of it the issue is in your Next button rather than it being a subform issue. As you stated in the comments the default navigation allows the form to work as expected.

Is this logic out in your Previous button OnClick Event? Also to be safe i would add in the OR statement in the below code to be extra sure that its catching nulls or blanks

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



回答2:


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


来源:https://stackoverflow.com/questions/43976564/ms-access-subform-not-displaying-records-and-not-navigating

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!