Search code examples
ms-accesstable-relationships

MS Access subform not displaying records and not navigating


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.


Solution

  • 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