Link to home
Start Free TrialLog in
Avatar of Hankwembo Christopher,FCCA,FZICA,CIA,MAAT,B.A.Sc
Hankwembo Christopher,FCCA,FZICA,CIA,MAAT,B.A.ScFlag for Zambia

asked on

Data Saving

The issue is based on this code below:

----- start of function code -----
Public Function LimitRecords( _
                    frm As Access.Form, _
                    Optional RecLimit As Integer = 1)

    ' Limit the number of records in the form passed as
    ' to no more than the number specified by .

    With frm.RecordsetClone
        If .RecordCount <> 0 Then .MoveLast
        frm.AllowAdditions = (.RecordCount < RecLimit)
    End With

End Function
'----- end of function code -----


=LimitRecords([Form], 1)


Because of using this code to limit the number of lines to be used in the sub form, though everything works fine but after saving data it does not refresh in readiness for the new data entry until I close the form and reopen again that is when it work again.
I have tried to use this code:
Me.Requery
In the sub form, well it has worked but it save directly immediately once the last control is done leaving the parent form data un saved. It does not give chance for corrections

Temporally I have now resorted to us the VBA code below:
Private Sub Refresh_Click()
DoCmd.Save
DoCmd.Close
End Sub
This now works Okay, but I have to keep on reopening until all transactions are finished

(2) Is there way to refer to a control from a subform to the other subform like the we do it when referring to the parent form:

Me.TTDate = Me.Parent!TTDate
 
Any help on this will be high appreciated.

Regards

Chris
ASKER CERTIFIED SOLUTION
Avatar of Gustav Brock
Gustav Brock
Flag of Denmark image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
<<(2) Is there way to refer to a control from a subform to the other subform like the we do it when referring to the parent form:>>

Me.Parent.OtherChild.Form.txtTextboxName

Open in new window


(Where OtherChild is the name of the 'sibling' subform control, as seen in the parent form's design)
Chris,

You had two people working with you on this question.  I believe Gustav’s post addressed the bulk of your question; mine addressed your second concern.

Please use the Request Attention button to reopen the question, and accept/award points to the first post.

Thanks -
Avatar of Hankwembo Christopher,FCCA,FZICA,CIA,MAAT,B.A.Sc

ASKER

I'm sorry I cannot see the re open button but all the same what worked perfectly well for me is as follows:

Replace re query with three staged code:

Private Sub Refresh_Click()
DoCmd.Save
DoCmd.Close
DoCmd.Open Form
End Sub
 
The above code worked very with the code below:

Public Function LimitRecords( _
                    frm As Access.Form, _
                    Optional RecLimit As Integer = 1)

    ' Limit the number of records in the form passed as
    ' to no more than the number specified by .

    With frm.RecordsetClone
        If .RecordCount <> 0 Then .MoveLast
        frm.AllowAdditions = (.RecordCount < RecLimit)
    End With

End Function

Once see the re open button I will do as per request many thanks to all.
Regards

Chris