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!

Subform updating problem using BeforeUpdate

Status
Not open for further replies.

0200050

Programmer
Jun 3, 2003
58
FI
Hello there,

I have a little databasesystem, that is 98 % ready. Only this one thing is annoying me out. Lets go for it.

I have a subform with custom browsing buttons(add new rec, go last, go first, go previous, go next).

This subform has also subform, but it doesn't have any browsing buttons. This another subform contains specific info related to this first subform.

At this first subform, there is one field required. Required, by adding a little functionality to check is the field empty, and when it is, do Cancel = True in the BeforeUpdate event.

The problem I have is this:

When I add a new record at this first subform, I don't fill the required field, and I browse to previous record, something extremely odd happens.

(I have Docmd.Gotorecord, , acPrevious coded into previous button.)

When I browse records, and stop to a record, that has something typed into this second subform, and NOW add new record, and don't fill the required field, and try to move to previous record, the program shows and error message.

Cool this far?
This is how this is supposed to happen, nothing more. BUT.

When I added the record, when I was on the record that has something typed onto this second subform, AND now I browsed previous record, the error occurs, AND

those things, texts, information, I typed at this second subform, where I started the adding of new record, were copied to this new record!

This information actually doesn't stay or save there, when I browse off the new record, but when Cancel = True in the BeforeUpdate occurs, it shows this info however just when adding new record and doing the mistake (did not fill the required field).

Most annoying problem... I might place the required thing direct to table, but Access's own error messages aren't so cool.

Do you happen to have any suggestions?
Thank you in advance.

-0200050-
 
And yes, in addition to this,

I hadn't this problem while using the Access's own record browsers (But I still need custom buttons, because the form needs some protection)


-0200050-
 
Are the 2 subforms properly linked, ie LinkMasterFields and LinkChildFields ?

Hope This Helps, PH.
Want to get great answers to your Tek-Tips questions? Have a look at FAQ219-2884 or FAQ222-2244
 
Thanks PHV for quick reply!

Yeah, this linking should be working fine, both, 1. subform, and 2. subform are connected together with same ID:s.

I tried to change the relations, but they seem to be ok already.

It does like this when malfunctioning: the Cancel = True only back ups the proceeding tryout of 1. subform, when the second subform isn't Cancelled at all!

2. subform goes right there, to IT'S previous record. Weird thing.

Any help will be highly appreciated.
 
Ok. This strange problem was occuring because of too much AllowEdits/Deletions/Additions confusing MS Access.

I removed now all of them, and it works. So, I have to only type better organized protection.

-0200050-
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top