new record

B

Bill H.

I want to populate a form with a few "constants" to speed data entry.

So, on the form's curren property, I used:

If Me.NewRecord Then
Me.Cost = mBaseCost
Me.Photo.Picture = ""
Me.CouncilDistrict = mCD
End If

Problem is, that can go on forever. Meaning that even if the user does not
put in any info, the new record button can be clicked on and on and on.

So, how do I stop a new record from being added to the table when the only
data entered is the "constant" data?

Thx.
 
C

chriske911

Bill H. presented the following explanation :
I want to populate a form with a few "constants" to speed data entry.
So, on the form's curren property, I used:
If Me.NewRecord Then
Me.Cost = mBaseCost
Me.Photo.Picture = ""
Me.CouncilDistrict = mCD
End If
Problem is, that can go on forever. Meaning that even if the user does not
put in any info, the new record button can be clicked on and on and on.
So, how do I stop a new record from being added to the table when the only
data entered is the "constant" data?

if you have other fields on your form than those you already supply
defaults for then set those to "value required = YES" in the table you
use to store those fields

that way a user cannot enter a new record and thus not click on new
record, without filling in that specific field or fields

that is, he or she can click but will get an error that a value is
required

grtz
 
J

John W. Vinson

I want to populate a form with a few "constants" to speed data entry.

So, on the form's curren property, I used:

If Me.NewRecord Then
Me.Cost = mBaseCost
Me.Photo.Picture = ""
Me.CouncilDistrict = mCD
End If

Problem is, that can go on forever. Meaning that even if the user does not
put in any info, the new record button can be clicked on and on and on.

So, how do I stop a new record from being added to the table when the only
data entered is the "constant" data?

Thx.

Make some other field required as Chriske911 suggests; or use VBA code in the
Form's BeforeUpdate event to check these fields.

Better might be to NOT explicitly dirty the record in the Current event.
Instead, set each of these fields' DefaultValue property; there will then be
no new record created until the user actually puts data into *some* control on
the form.
 
B

Bill H.

Well, that idea created some issues.

First being that if a user clicks on new record, and then decides NOT to
continue, they get stuck in a loop saying that the field is required. Only
way out then is to click on the close button, get another error msg, and
then finally close the form.

:)

And some of the data I'm pre-populating on the form just goes into an
unbound text box, so I can't set a default to that. At least it didn't work
when I tried it.

--Bill
 
J

John W. Vinson

Well, that idea created some issues.

First being that if a user clicks on new record, and then decides NOT to
continue, they get stuck in a loop saying that the field is required. Only
way out then is to click on the close button, get another error msg, and
then finally close the form.

:)

<Esc><Esc>
clears all fields;
Click close button or Alt-F4
And some of the data I'm pre-populating on the form just goes into an
unbound text box, so I can't set a default to that. At least it didn't work
when I tried it.

An unbound control doesn't dirty the form so doesn't cause the problem.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top