Problem adding records in a form

S

sergiosr

Hi,

I have a problem that I am trying to solve in the last 3-4 days. I have
a form and a subform and I want to prevent users for entering data
unless they press the "add record" button. When they press that button
there are many bugs that are troubling me. My biggest issue is that i
want the new record to be saved only if they complete adding it. That
means that if they exit without adding all the information nothing
should be saved.

I think this sounds simple, but it gets more complicated because of the
subform. Is somebody willing to tell me his email so that I send him my
database and he can take a look at it?

Thanks!

Sergios
 
V

Van T. Dinh

See the thread "Cancel changes to form and subform" started by "Gezza
Collins" on
Sunday, 3 April 2005 16:48 (my datetime, GMT + 10:00) in the Access Forms
newsgroup.
 
S

sergiosr

I saw that thread but it wasnt very helpful.

Let me try explain you what exactly i need.

My main form stores information about people and the subform stores
information about questionaires that they have to answer once a year.
That means that every person can have many questionaires(one for every
year).
When the database is complete, i will give it to somebody to add all
the people that are involved with this. That means the first step is to
add records only for the main form (people). The second step is to add
questionaires for every person(whenever needed - once a year for every
person). The third step is to add more people if needed in the future.

I also want whoever is using the database, not to be able to delete or
edit information. I want them to be able to add information only when
they click the "add record" button. When they click on "add record"
button I want them to be able to add either a person, or a questionaire
(I don't think i need both of them to be added at the same time, unless
that is easy to do). If I manage to solve this problem I will also want
to include an "edit record" button so that edits are also possible if
needed.

In addition to that i want to have a "cancel" button and a "save"
button so that the new record is saved only if i click "save". If I
click "cancel" i want the information to be discarded.

Does this make sense? Am I asking too much?

Thanks
 
V

Van T. Dinh

That's the point of the thread I referred to. The Add button is easy
(GoToRecord method) but says, the user is half way through the data entry
for a Person and for some reason, click the Subform, i.e sending the Focus
to the Subform, Access will attempt to save the Person Record straight away.
You can only stop this by using the MainForm_BeforeUpdate to confirm whether
the user wants to save the Person Record or not (which will confuse the user
because from the user's point of view, it is a single process and the user
doesn't know about the One-to-Many relationship).

Let's assume that you use the BeforeUpdate Event to show a MsgBox asking the
user to confirm saving. If the user selects Yes, no problems. If the user
select No, you will need to cancel the update but then the Focus will remain
on the MainForm (while the user wants to move to the Subform).

I am fairly sure I suggested a few alternatives including hiding the Subform
(so that the user doesn't attempt to go to it until the user actually saves
the Record on the MainForm. This may be suitable in your case.
 
Top