Solved subform remains blank after new record saved

Jaks

New member
Local time
Today, 00:20
Joined
Apr 15, 2024
Messages
3
hi all

I have an access db front end, with a dataverse backend. My main data entry form "policies" has a variety of subforms (with the correct Parent and Child ID assigned). the master form itself only updates fields in the table policies. Everything works flawlessly on existing records in the Policies table, hence I also know the Parent Child link works fine. My issue is the following, appreciate your help if possible. It relates to opening the master form in new recordmode which results in the subform never updating until the master form has been closed and reopened:

I open my main data entry form "Policies" in a new record mode. I use the following VBA code in the .open event to go to a new record

If IsNull(Me.OpenArgs) Then

Me.AllowEdits = True
Me.AllowAdditions = True
Me.DataEntry = True
DoCmd.GoToRecord , , acNewRec

obviously all the subforms are unpopulated as there is no ID saved yet. After the first few required fields have an entry, a save is forced.One of these fields is a combobox linking to a related table (risks), and stores the foreign key in the policies table. that part all works fine.

My issue is that the subforms remain empty even after the foreign key is saved, until I close the master form alltogether and reopen it again. It is like there is no parent child ID link, unlike when the form was opened on an existing record. I can see the Key in my table, so I know it has been correctly saved.

To solve this, I was using a simple .requery on the subforms (me.subfrmcontrol.form.requery). However, this does not help , the subform remains blank. I tried .refresh .repaint, I tried to force a refresh by doing me.subfrmcontrol.form.recordsource = me.subfrmcontrol.form.recordsource, I overwrote the .recordsource with a new Select query... I cannot get the subform to show the linked record, until I close the master form the child form remains blank.

Once the form has been closed and I open the master form on an existing record, then it works flawlessly.

I read somewhere that using SQL server or Dataverse as backend changes the way Parent and Child behaviour changes and the link isn't instantenous. Suspect that is the cause here.

My main question is : how can I get the subform to show the correct linked record, without having to close the master form?

Thanks a lot for your views.
 
Try removing me.dataentry = True
 
You might try comment out the me.dataentry property
The default value for this property is "False" which means that Access opens the form and shows the existing records. However, if set to True, the Data Entry property of the form specifies that the form will only show a blank record. Suggests the saving of the main form record then menas a new blank record - for which the subform is of course blank
 
thanks both. tried all combinations of me.dataentry, also for the subform. No change in behaviour

EDIT: I found an old reference to me.dataentry = true in the .open event of the subform ! that solved it. Thanks so much for pointing me in the right direction
 
Last edited:

Users who are viewing this thread

Back
Top Bottom