Continuous Forms New Records

  • Thread starter Thread starter Ian Meek
  • Start date Start date
I

Ian Meek

I have a continuous form used as a subform. When opened in
Add mode and enter 1 record I get a blank record as well.
This presumably results from the new record control opened
when the 1st record is entered. How do I avoid this<
 
I have a continuous form used as a subform. When opened in
Add mode and enter 1 record I get a blank record as well.
This presumably results from the new record control opened
when the 1st record is entered. How do I avoid this<

You don't actually get a blank record (if you don't believe me, try to delete
that "record"). Once you start to edit a record, the form displays a "new
record" position in the form. If it didn't, you wouldn't be able to create
another new record once you started the first. This behavior cannot be changed
as long as the form's "AllowAdditions" property is set to "True" and if you set
that property to "False", you won't be able to type in a new record.
 
Bruce
Thanks but I can delete what I am calling a blank record.
To be specific my subform is bound to a table with only 2
fields, one of which is picked up on the subform by
reference to its parent, the other needs to be entered.
In respect of the unwanted "blank" record. The first field
is entered in the table but the 2nd field is blank because
it was not entered on the second "record" shown on screen.
 
Thanks but I can delete what I am calling a blank record.
To be specific my subform is bound to a table with only 2
fields, one of which is picked up on the subform by
reference to its parent, the other needs to be entered.
In respect of the unwanted "blank" record. The first field
is entered in the table but the 2nd field is blank because
it was not entered on the second "record" shown on screen.

Are you saying that the first field is filled in with code leaving the second
field to be filled in by the user and that the field is left blank when the user
doesn't fill it in? You seem to be confusing fields with records and the
statement in your last sentence is confusing to me. If your table contains 2
fields and one of them is not being filled in, then you have a blank field, not
a blank record. In order to have a blank record, both fields must be empty.
 
Bruse

Sorry for my lack of precision. You are right and your
first sentence describes what I am trying to do.
The problem must be common with continuous forms and no
doubt I have missed an obvious point in setting the form
up.
I have tried unlinking the subform from the main form (by
deleting Child and Master field references) but this makes
no difference
 
Sorry for my lack of precision. You are right and your
first sentence describes what I am trying to do.
The problem must be common with continuous forms and no
doubt I have missed an obvious point in setting the form
up.

This problem is most common when code is used to populate a field without the
user's interaction.
I have tried unlinking the subform from the main form (by
deleting Child and Master field references) but this makes
no difference

All that will do is allow all child records to be visible in all parent records.

Probably the easiest solution would be to set the "Required" property for the
field that isn't being filled in to "Yes" (this is done with the table open in
design view). This way no record can be saved unless the problem field has data
entered into it.
 
Bruce

Thanks but the suggested solution produces an error
message which I can't hide. Or at least I can not devise
an error handler which hides it.

have solved the immediate problem by running a delete
query on closing the form which deletes any record with an
unfilled field.
However I am still mystified as to why the system
automatically enters the unwanted field and record. Before
closing the form, i.e. while it is still visible, the
field still shows a zero entry. It somehow enters the
field after the form's close procedure is initiated. I
can't see that my form is out of the ordinary, so can only
conclude that the problem is endemic with continuous
forms, but find that hard to believe.
-----Original Message-----

This problem is most common when code is used to populate a field without the
user's interaction.


All that will do is allow all child records to be visible in all parent records.

Probably the easiest solution would be to set
the "Required" property for the
 
However I am still mystified as to why the system
automatically enters the unwanted field and record. Before
closing the form, i.e. while it is still visible, the
field still shows a zero entry. It somehow enters the
field after the form's close procedure is initiated. I
can't see that my form is out of the ordinary, so can only
conclude that the problem is endemic with continuous
forms, but find that hard to believe.

If a record is automatically being generated, there must be some code doing so.
Continuous forms are no different from any other forms in this respect.
Continuous forms and forms in "datasheet" view both show a row for a "new"
record, by design, but this doesn't save any data to the table on its own.

Since you appear to be using VBA to execute a delete query, you could, instead,
implement some code in the form's "BeforeUpdate" event procedure to undo the
record if that field is empty, but if there is other code that is behind all of
your troubles, this might just cause another whole set of problems. The "Undo"
code might look like this:

'*********EXAMPLE START
Private Sub Form_BeforeUpdate(Cancel As Integer)
On Error GoTo Form_BeforeUpdate_Err

'Undo record if a certain field is empty
If Len(Trim(Me![ProblemField]) & "") = 0 Then
Me.Undo
End If

Form_BeforeUpdate_Exit:
Exit Sub

Form_BeforeUpdate_Err:
MsgBox Err.Description
Resume Form_BeforeUpdate_Exit

End Sub
'*********EXAMPLE END
 
Bruce


Thanks for your help and persistence!
-----Original Message-----
However I am still mystified as to why the system
automatically enters the unwanted field and record. Before
closing the form, i.e. while it is still visible, the
field still shows a zero entry. It somehow enters the
field after the form's close procedure is initiated. I
can't see that my form is out of the ordinary, so can only
conclude that the problem is endemic with continuous
forms, but find that hard to believe.

If a record is automatically being generated, there must be some code doing so.
Continuous forms are no different from any other forms in this respect.
Continuous forms and forms in "datasheet" view both show a row for a "new"
record, by design, but this doesn't save any data to the table on its own.

Since you appear to be using VBA to execute a delete query, you could, instead,
implement some code in the form's "BeforeUpdate" event procedure to undo the
record if that field is empty, but if there is other code that is behind all of
your troubles, this might just cause another whole set of problems. The "Undo"
code might look like this:

'*********EXAMPLE START
Private Sub Form_BeforeUpdate(Cancel As Integer)
On Error GoTo Form_BeforeUpdate_Err

'Undo record if a certain field is empty
If Len(Trim(Me![ProblemField]) & "") = 0 Then
Me.Undo
End If

Form_BeforeUpdate_Exit:
Exit Sub

Form_BeforeUpdate_Err:
MsgBox Err.Description
Resume Form_BeforeUpdate_Exit

End Sub
'*********EXAMPLE END

--
Bruce M. Thompson
(e-mail address removed) (See the Access FAQ at http://www.mvps.org/access)within the newsgroups so that all might benefit.<<


.
 
Back
Top