Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Why does the Form's Record Update but not the Form

Status
Not open for further replies.

GREABR

IS-IT--Management
Aug 19, 2002
21
I have a form that gets is data from a query. The form has a field (one of a composite Primary Key) that is filled from a combo box. After making a selection from the combo box, the form is dirty. Here is where it gets wierd - When I enter another field/TextBox on the form, the record updates, but the form does not.

After the record updates, all of the Text boxes on the form change to display "#deleted", because the form loses its pointer to the updated record.

This also happens when I save or close the form while it is dirty. First the record updates and the pointer is lost (#deleted in textboxes), then the form goes to beforeupdate and prompts me to save Y or N. If I say no, the event is canceled, but the record is saved.

Now it gets wierder - this only happens when I open the form to an added record (allowadditions is true and the data is EOF because of the Filter). this does not happen when I edit the records using the same form, or if I add them with DoCmd using the same form.

Much of the detail for this error are covered in a previous post "Add Record on Open Form Behavior". In that post we cover alot of ground on Normalization and relational design but do not descover the cause of this behavior.

"Don't be afraid to do things wrong, before you do them right"
Bradley Greaves
 
The problem is because of using the filter. This brings up all sorts of complications that I prefer not to use it at all.
After adding the new record the record does not satisfy the Filter condition, hence the #deleted appears and the form clears itself.
Why don't you set the fitler to off and Use DataEntry property of the form to clear the form for New additions.

if you use Docmd.Openform use acFormAdd for dataMode.
Or else
When you open the form For New Addition set form.Dataentry = true.
Or you can use a macro to open the form which opens in Add Data Mode

Best of luck
 
MinusM

Yes, I agree. I was under some pressure to complete this project, so I just wrote extra code to handle the add record instead of allowing the form to do it auto. (something along the lines of what you recomended).

Just wondering, do you know how the record is able to update with out the form updating, even when the datasource is bound to the form?


"Don't be afraid to do things wrong, before you do them right"
Bradley Greaves
 
What do you mean by the Form does not update?

The Event Form AfterUpdate is not triggered?
This event is triggered only after the record is updated. But since the filter action is On maybe it is missing to be executed. This has happened to me when the form is closed right after updating a field with the focus still in the same field.
Wierd things do happen

You can check one more thing. Comment out the After update code. Re enter the Event Procedure from the form's property sheet(Not from the code window). Then copy the code again into the Procedure.

This may help

Best of luck


 
MinusM,

Just to confirm,

1. I Open the form to a new Record
2. I Fill in some Fields
3. I Close the Form, which triggers the beforeupdate event for the Form
4. I cancel out of the update for the form
5. I find the record was saved in the table.

...Don't seem right, dud'nt it.

One other thing I have discovered regarding this, is that it only happens under this condition:

Form A is a Parent Table and has a subform showing Child Records. The Subform displays records as a datasheet with record selectors and only a couple of columns of key data fields. A button on the subform opens Form B to the selected record on the subform, and displays all fields for the child record. Form B is where I have this update problem.

Anyway, I feel like moving on but I wanted to at least understand what may be going on with the record and the form to cause this behavior.

Thank you for your help.











"Don't be afraid to do things wrong, before you do them right"
Bradley Greaves
 
If Form B is a subform to Form A, then canceling the update in the before update event of Form A will be too late, since the update for the subform has already run. You could try canceling in the before update event of the subform, which should work.
 
No, Form B is not a subform of Form A. Form A has a Subform with the same datasource as Form B, used to display only a couple of fields from the child records (read only). Form B opens - in addition to - Form A and the subform, to display the complete record and allow adds/edits/deletes of the child records.



"Don't be afraid to do things wrong, before you do them right"
Bradley Greaves
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top