Data Entry not working as Intended (1 Viewer)

Valentine

Member
Local time
Yesterday, 19:20
Joined
Oct 1, 2021
Messages
198
I have Form Soldier Data, with subform Leave. Subform Leave is set to data entry and has parent child with ID so they link. When i open Soldier Data the subform still has the record last submitted instead of being blank. Is there a way to set default blank or maybe have on open it sets the fields to blank in the subform?
 

theDBguy

I’m here to help
Staff member
Local time
Yesterday, 16:20
Joined
Oct 29, 2018
Messages
18,972
Just thinking out loud, but perhaps try adding a filter to the subform to only include records past a certain creation or leave submission date, like today?

Edit: Or, only display records created today?
 

Valentine

Member
Local time
Yesterday, 19:20
Joined
Oct 1, 2021
Messages
198
I don't want it to display ANY records. I want it to open blank and be fillable.
 

theDBguy

I’m here to help
Staff member
Local time
Yesterday, 16:20
Joined
Oct 29, 2018
Messages
18,972
I don't want it to display ANY records. I want it to open blank and be fillable.
Well, if you have a creation date that defaults to today and add a filter to only display records created after today, wouldn't the form show up as blank? As I said earlier, just thinking out loud here...
 

Valentine

Member
Local time
Yesterday, 19:20
Joined
Oct 1, 2021
Messages
198
that sounds like it would work, Where would I put the filter?
 

theDBguy

I’m here to help
Staff member
Local time
Yesterday, 16:20
Joined
Oct 29, 2018
Messages
18,972
Hi. Just out of curiosity, I decided to conduct a little experiment by creating a simple form/subform. Here's how it normally looks.
1652118989720.png

But as soon as I turn Data Entry on in the subform, this is what happens.
1652119064385.png

So, I am not sure why Data Entry is not working for you. Are there any code behind the forms?

Just curious...
 

theDBguy

I’m here to help
Staff member
Local time
Yesterday, 16:20
Joined
Oct 29, 2018
Messages
18,972
that sounds like it would work, Where would I put the filter?
In the subform. But, I just posted the result of a little test I did to see if using Data Entry in a subform was a problem. It doesn't seem so. Perhaps, there's another reason why it's not working for you.
 

Valentine

Member
Local time
Yesterday, 19:20
Joined
Oct 1, 2021
Messages
198
If you put a couple records into ChildSubForm save them and then open ParentA do you not see the most recent entry in ChildSubForm?
 

bob fitz

AWF VIP
Local time
Today, 00:20
Joined
May 23, 2011
Messages
4,442
Setting the "Data Entry" property of both forms to Yes should give the desired behaviour, if I've understood the requirement correctly.
 

theDBguy

I’m here to help
Staff member
Local time
Yesterday, 16:20
Joined
Oct 29, 2018
Messages
18,972
If you put a couple records into ChildSubForm save them and then open ParentA do you not see the most recent entry in ChildSubForm?
Do you mean open ChildSubForm as a standalone form and enter records in it first, then close it and open the Parent Form to see if the ChildSubForm is Empty?
 

Valentine

Member
Local time
Yesterday, 19:20
Joined
Oct 1, 2021
Messages
198
Do you mean open ChildSubForm as a standalone form and enter records in it first, then close it and open the Parent Form to see if the ChildSubForm is Empty?
Yeah, Since i have my soldier data form as my ParentA and Leave is my ChildSubForm I have Leave as data entry and my soldier data is not data entry. They are linked through ID and when I go to any soldier the leave subform has the most recent data in the boxes instead of being blank.
 

arnelgp

..forever waiting... waiting for jellybean!
Local time
Today, 07:20
Joined
May 7, 2009
Messages
16,394
that is not a Subform and therefore will not work.
if you still want to use the standalone form (which you call subform), remove the linking fields.
add code to the BeforeInsert event of the form (subform, whichever) to insert the PK of soldier to the FK of your leave table:

private sub form_before(cancel as integer)
if syscmd(acSysCmdGetObjectState, acForm, "yourSoldierFormNameHere") <> 0 Then
me!theSubformFKFieldTextbox = Forms("yourSoldierFormNameHere")("thePKTextboxName")
end if
end sub
 

theDBguy

I’m here to help
Staff member
Local time
Yesterday, 16:20
Joined
Oct 29, 2018
Messages
18,972
Yeah, Since i have my soldier data form as my ParentA and Leave is my ChildSubForm I have Leave as data entry and my soldier data is not data entry. They are linked through ID and when I go to any soldier the leave subform has the most recent data in the boxes instead of being blank.
Okay, the file I used was at work. I will try what you requested as soon as I get to work and let you know the result.
 

Valentine

Member
Local time
Yesterday, 19:20
Joined
Oct 1, 2021
Messages
198
OK I don't think i have portrayed my scenario properly. I have From "Soldier Data" that is not data entry, has tabs and 1 of the tabs is Leave and inside that tab I have a subform "Subform Leave" which is data entry. I have set up Link Master Fields and Child Fields set to the DoD ID of the soldier. What happens is that when i open "Soldier Data" and go to any soldier and open the leave tab for that soldier it has the information of the most recent entry, and what i want is that to be blank.

Soldier Data source is tblRoster
Subform Leave source is tblLeave
 

Minty

AWF VIP
Local time
Today, 00:20
Joined
Jul 26, 2013
Messages
9,286
Set the subform to data entry = true then, no filters or anything else required?

Every time the parent record change it will reset the subform to a blank new line record, or at least it should do.
 

arnelgp

..forever waiting... waiting for jellybean!
Local time
Today, 07:20
Joined
May 7, 2009
Messages
16,394
OK I don't think i have portrayed my scenario properly
yes you did not.
when asked if your subform is Standalone, your answer is yes (post #11).

if really a subform, go in design view and set Data Entry to Yes.

data_entry.png
 

theDBguy

I’m here to help
Staff member
Local time
Yesterday, 16:20
Joined
Oct 29, 2018
Messages
18,972
If you put a couple records into ChildSubForm save them and then open ParentA do you not see the most recent entry in ChildSubForm?
As requested, I temporarily modified the ChildSubform to add the ParentID field and set Data Entry to No and then opened it as a standalone form. As you can see, it shows three records where two of them belong to ParentA.
1652372796706.png

Then, I added one more child record for ParentA as shown below.
1652372901343.png

I closed ChildSubform (without saving it, so the Data Entry setting will stay as Yes) and opened the ParentMainForm as shown below.
1652373176872.png

As you can see, the subform still showed up as empty because Data Entry is set to Yes.

Hope that helps...
 

Valentine

Member
Local time
Yesterday, 19:20
Joined
Oct 1, 2021
Messages
198
This is soo weird then. I have no clue why my subform is showing data.
Top Half.PNG
Mid.PNG
Bottom.PNG
 

theDBguy

I’m here to help
Staff member
Local time
Yesterday, 16:20
Joined
Oct 29, 2018
Messages
18,972

Users who are viewing this thread

Top Bottom