Solved Subform adding blank record (1 Viewer)

dullster

Member
Local time
Today, 03:54
Joined
Mar 10, 2025
Messages
43
I have a subform that I am entering records related to the ClientID on the main form. It creates an extra blank entry when i enter the line prior. How do i stop it from doing that. Image attached.
 

Attachments

it is hard to tell without seeing the Code on your form.
 
Can we assume you aren’t referring to the line at the bottom that displays default values but isn’t a new record until you modify any field in the bottom line?
 
I am assuming that is where the blank rows are coming from. I'll check again tomorrow as I had a couple other errors to work through.
 
When you start to add a new record in the subform you will automatically generate a new blank row.

This is how a Continuous Form works.
 
Are we talking about a line like the last one here?
1744215989800.png
 
Is there a way to keep the line from loading empty?
No. That is the way bound forms work. If you think you know better than Access, you can use unbound forms. That opens a whole new can of worms as well as requiring lots of code to handle all the things manually that Access handles for you when a form is bound.

You can split the baby by changing the subform to not allow additions and by adding unbound controls which the user fills and you validate and then use DAO to insert.
 
It is a datasheet form. I want additions as it is for entering data. Is there a way to keep the line from loading empty?
Yes.

1. Make the subform AllowAdditions property = False.

2. Add a button to the main form called something like 'cmdAddNew'

3. Add the following code to the button click event:
Code:
Private Sub cmdAddNew_Click()

' Make sure you use the name of the subform CONTROL
'  - it may be different from the name of the subform used as its SourceObject

  Me.NameOfSubformControl.Form.AllowAdditions = True
 
End Sub

4. Add the following code to your subform's AfterInsert event:
Code:
Private Sub Form_AfterInsert()

  Me.AllowAdditions = False

End Sub

When you load the form the blank line won't be there.

When you click cmdAddNew the new line will appear for data entry.

When you start adding the new record another new empty line will appear below it - you will have to live with this!

(Also, you will have to write more code to deal with when the user decides they didn't want to add a new record after all, but I'll leave that up to you!)

When you have finished entering the data and tab out of the record then the additional new empty row will disappear again.

Quite a lot of work for a not perfect solution - you are probably better off just putting up with the empty line waiting there ready for your next record entry!
 
It creates an extra blank entry when i enter the line prior. How do i stop it from doing that. Image attached.
What do mean by "enter the line prior"? There are six records entered into the subform and the blank (add new) record line is for entering in another record. If you look at your table it should have only the six new records that you entered in the subform and that's it. Are you saying an addition blank record is getting created in the table? There are no blank entries in your screenshot, just the add new record line.
 
I found i had redundant joins. Once i fixed those and rebuilt the form and sumform it fix my problem. Thank you.
 

Users who are viewing this thread

Back
Top Bottom