Any way to limit continuos form to one new entry at a time.

K

KevinC

I use a continuous form with an a add record button which sets the allow
additions property to true and sets a confirm addition button as visible.
This part works fine however I want to run some code to add certain values
to other hidden fields in the record dependant on the entries and in the
record and verify the record before the user moves to adding the next
record. However at the moment as soon as any field is dirty another new
blank record is added to the form and the user can start entering another
record before the record has been verified and fully updated. I have tried
various combinations using the beforeupdate, dirty event, dataentry and
allowadditions properties and methods but cant find a way round this.

The user needs to see other records as prompts when he enters the record
hence the use of a continuous form also this is a subform so using a
specific discreet data entry form would cause other problems, be less user
friendly, and less in sympothy with the rest of the project.
 
D

Dirk Goldgar

KevinC said:
I use a continuous form with an a add record button which sets the
allow additions property to true and sets a confirm addition button
as visible. This part works fine however I want to run some code to
add certain values to other hidden fields in the record dependant on
the entries and in the record and verify the record before the user
moves to adding the next record. However at the moment as soon as any
field is dirty another new blank record is added to the form and the
user can start entering another record before the record has been
verified and fully updated. I have tried various combinations using
the beforeupdate, dirty event, dataentry and allowadditions
properties and methods but cant find a way round this.

The user needs to see other records as prompts when he enters the
record hence the use of a continuous form also this is a subform so
using a specific discreet data entry form would cause other problems,
be less user friendly, and less in sympothy with the rest of the
project.

I may be overlooking something, but it seems to me that you can easily
keep the user from moving on to another record without clicking your
"confirm additions" button by having that button set a module-level flag
variable to indicate that it's okay to save the record. Then you'd have
code in the form's BeforeUpate event that would check the flag variable
and cancel the event if the flag wasn't set. In the AfterUpdate event
you'd reset the flag as well as turning AllowAdditions off.

I don't know any good way to prevent another "new record" from appearing
the moment the user starts entering data in the first control of the new
record. The only thing I can think of is to change the design
altogether, and not to use bound controls for entering new data at all.
Instead, you could have a bunch of unbound controls in the form footer
wherein you'd enter the new data. Your Add Record button would make the
form footer visible, and your Confirm Addition button would verify the
contents of these controls, insert a record with those contents, do
whatever processing is required, requery the form to make the added
record appear in the detail section, and then hide the form footer
section again.
 
E

Emilia Maxim

---------- "KevinC said:
I use a continuous form with an a add record button which sets the allow
additions property to true and sets a confirm addition button as visible.
This part works fine however I want to run some code to add certain values
to other hidden fields in the record dependant on the entries and in the
record and verify the record before the user moves to adding the next
record. However at the moment as soon as any field is dirty another new
blank record is added to the form and the user can start entering another
record before the record has been verified and fully updated. I have tried
various combinations using the beforeupdate, dirty event, dataentry and
allowadditions properties and methods but cant find a way round this.

Kevin,

the 'new record' displayed the moment you dirty a real new one does
not exist. This is a behaviour by design, just like displaying one
empty record when there are no records at all.

Now to the problems. Data verification usually goes in the form's
BeforeUpdate event. This fires every time Access tries to save the
record, either the user clicks the Save command, goes to another
record or closes the form. If the data isn't complete or valid, set
Cancel to True, and the record won't be saved. If it didn't work for
you, then there must have been some other problem, BeforeUpdate is
reliable.

As for filling dependant values, you can do it in the AfterUpdate of
the relevant controls. I.e. if Textbox3 depends on Textbox1 and
Textbox2, then you'll need the AfterUpdate events of both Textbox1 and
Textbox2 (or you can use the BeforeUpdate event of the form for such
calculations too).

Finally, in the AfterInsert event of the form you could reset the
AllowAdditions property. It would be user friendly to have a second
command button 'Save new data' invisible and identical in size with
the 'Add' button, and having exactly teh same position. When 'Add' is
clicked, you could set 'Add' invisible and 'Save' visible. When 'Save'
is clicked then viceversa.

Best regards
Emilia

Emilia Maxim
PC-SoftwareService, Stuttgart
http://www.maxim-software-service.de
 
J

jfp

ahhh -- but as you pointed out to me today (post re weird behavior in
BeforeUpdate) unbound controls function differently from bound ones --
at least insofar as Undo is concerned, and perhaps other areas as well.
-=-=
Dirk Goldgar wrote:
...
 
D

Dirk Goldgar

jfp said:
ahhh -- but as you pointed out to me today (post re weird behavior in
BeforeUpdate) unbound controls function differently from bound ones --
at least insofar as Undo is concerned, and perhaps other areas as
well. -=-=

True enough, but that doesn't mean there's no use for them. You just
have to allow for the differences. In this case, the most likely issue
will be detecting whether this ersatz "new record" is dirty.
 

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