Avatar of Hankwembo Christopher,FCCA,FZICA,CIA,MAAT,B.A.Sc
Hankwembo Christopher,FCCA,FZICA,CIA,MAAT,B.A.Sc
Flag 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
Microsoft AccessVBA

Avatar of undefined
Last Comment
Hankwembo Christopher,FCCA,FZICA,CIA,MAAT,B.A.Sc

8/22/2022 - Mon
ASKER CERTIFIED SOLUTION
Gustav Brock

THIS SOLUTION ONLY AVAILABLE TO MEMBERS.
View this solution by signing up for a free trial.
Members can start a 7-Day free trial and enjoy unlimited access to the platform.
See Pricing Options
Start Free Trial
GET A PERSONALIZED SOLUTION
Ask your own question & get feedback from real experts
Find out why thousands trust the EE community with their toughest problems.
mbizup

<<(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)
mbizup

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 -
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
Your help has saved me hundreds of hours of internet surfing.
fblack61