Locking form to single record

R

Robert

Is there any way to lock a form to a newly added record? Until now I
have just been using the required property of the fields in the source table
as validation. The form I am currently working on has a subform in the
middle with required fields before and after. When you go into the subform
the required fields coming after the subform in the parent form will throw a
pop-up error because an attempted save occurs when leaving the parent form.
My solution was to remove the close button, set the tab cycle to current
record, and remove record navigators given a new entry and validate a new
record in my code through custom save and close buttons. The mousewheel
still presents a problem for moving to a new record and bypassing my code.
I'm running Access 2000 so I dont have the onMouseWheel form control.
Basically what I am trying to accomplish is to have the validation occur at
the point of save or close. Also, if all the required's have been filled-in
prior to entering the subform then the record will save on entering the
subform without the user hitting the save button. Is there any way to
prevent saving unless done through Save command button containing validation
code?
 
T

TonyT

Hi Robert,

google MouseHook.dll for A2k, it allows you to turn on/off mouse scroll
wheel action.

Access automatically saves (or tries to) any form when the focus leaves it
and goes to the subform. You can use the forms beforeUpdate event to
validate/ cancel the save event prior to saving.
The best approaches would be to either, not allow entry to the subform until
the required info is entered (eg move the subform to the end and *force* the
user to complete the rest first), or, to save the record with default values
in place, and then change to dataEntry=false to edit them as required after
the subform has been updated.

The use of a subform assumes that the data in the subform is from another
data source, that is linked to a field on the main form, if their is no
*actual* (saved) data in the main forms underlying table, then the subform
link field has nothing to reference.

Probably telling you stuff you already know, if so, sorry, but always easier
to assume no knowledge!!

TonyT..
 

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