How To Stop Acces From Update The Record When The Subform Query Is On Focus?

C

Chipcom

Hi

I need to know how to stop acces from update the record when the
subform query is on focus?

Thanks
 
D

Dirk Goldgar

In
Chipcom said:
I need to know how to stop acces from update the record when the
subform query is on focus?

If you mean that you want to keep the main form's record from being
saved when the subform gets the focus, the only ways you can do that
are:

1. Have the main form be unbound. In that case your own code has to do
the job of reading the record, assigning its field values to the
controls on the form, detecting whether the values in the controls have
changed, assigning them back from the controls to the fields in the
record, and saving the record when you think it is appropriate.

2. Have the main form be bound, but keep all the controls unbound. Your
code has to navigate the form's recordset and assign values from the
recordset to the controls on the form, and then back again when you're
ready to save the record. Since the changes to the controls don't
affect the form's recordset directly, those changes won't be saved when
the focus goes to the subform, only after your code assigns the values
from the controls to the underlying fields and then you navigate the
form to another record, or close the form, or otherwise force a save.
 
C

Chipcom

In


If you mean that you want to keep the main form's record from being
saved when the subform gets the focus, the only ways you can do that
are:

1. Have the main form be unbound. In that case your own code has to do
the job of reading the record, assigning its field values to the
controls on the form, detecting whether the values in the controls have
changed, assigning them back from the controls to the fields in the
record, and saving the record when you think it is appropriate.

2. Have the main form be bound, but keep all the controls unbound. Your
code has to navigate the form's recordset and assign values from the
recordset to the controls on the form, and then back again when you're
ready to save the record. Since the changes to the controls don't
affect the form's recordset directly, those changes won't be saved when
the focus goes to the subform, only after your code assigns the values
from the controls to the underlying fields and then you navigate the
form to another record, or close the form, or otherwise force a save.




Hi

Tell me please, is it possible to set the form to be unbounded and
after the update to set it with control source with VBA?
if this is not possible what is the shortest way to do that?
Can you please show an example with 2 fields of the shortest way?

Thanks
 
C

Chipcom

Hi

Tell me please, is it possible to set the form to be unbounded and
after the update to set it with control source with VBA?
if this is not possible what is the shortest way to do that?
Can you please show an example with 2 fields of the shortest way?

Thanks- Hide quoted text -

- Show quoted text -


Any idea?
 
D

Dirk Goldgar

In
Chipcom said:
Tell me please, is it possible to set the form to be unbounded and
after the update to set it with control source with VBA?
if this is not possible what is the shortest way to do that?
Can you please show an example with 2 fields of the shortest way?

I'm not sure what you're asking. After the update of what? Are you
talking about setting a control's ControlSource property, or the form's
RecordSource property, or a combination of the two? Please describe in
greater detail what it is you want to do, and what circumstances make
you want to do it. I ask that last question because it may have some
bearing on the answer.
 
C

Chipcom

In


Sorry -- I've been too busy to look in the newsgroup.


Hi Dirk


I am talking about that when I focus on the sub form Access saves the
record.
You explained to me that there is two ways to save the record when the
user is want and I am talking about the Form's ControlSourcre :
Is there a way to unbound the Form with VBA and when the sub form is
on focus and access is trying to save the unbound form to assign the
table name to the ControlSource of the form?

If this is not possible what is the shortest way to do that?
Can you please show an example with 2 fields of the shortest way?

Thanks
 
J

John W. Vinson

I am talking about that when I focus on the sub form Access saves the
record.

The reason that it does this is that - typically - a Form is used for the
"One" side of a one to many relationship, and the Subform for the "many".
Access must save the "one" side record before the subform starts creating
"many" side records, in order to ensure that relational integrity is enforced;
otherwise the subform could create records not bound to any mainform record.

Why do you feel that you need to defeat this?
You explained to me that there is two ways to save the record when the
user is want and I am talking about the Form's ControlSourcre :

Recordsource, I guess you mean?
Is there a way to unbound the Form with VBA and when the sub form is
on focus and access is trying to save the unbound form to assign the
table name to the ControlSource of the form?

This is really confusing, Chipcom. Access isn't ever going to try to save the
unbound form - it's UNBOUND, it's got noplace to save. You can explicitly open
a Recordset and write code to copy data from the unbound form controls into
the table - but what you would end up with is *EXACTLY* what you get with the
bound form: save the mainform record first, then save the subform records.

What *real life problem* are you trying to solve with this code?


John W. Vinson [MVP]
 
C

Chipcom

In


If you mean that you want to keep the main form's record from being
saved when the subform gets the focus, the only ways you can do that
are:

1. Have the main form be unbound. In that case your own code has to do
the job of reading the record, assigning its field values to the
controls on the form, detecting whether the values in the controls have
changed, assigning them back from the controls to the fields in the
record, and saving the record when you think it is appropriate.

2. Have the main form be bound, but keep all the controls unbound. Your
code has to navigate the form's recordset and assign values from the
recordset to the controls on the form, and then back again when you're
ready to save the record. Since the changes to the controls don't
affect the form's recordset directly, those changes won't be saved when
the focus goes to the subform, only after your code assigns the values
from the controls to the underlying fields and then you navigate the
form to another record, or close the form, or otherwise force a save.



Can you please show me an example of the firs way?


Thanks
 

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