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 biv343 on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Subform won't take input 1

Status
Not open for further replies.

kupe

Technical User
Sep 23, 2002
376
One form, two subforms in a new db. The three work well together, except when it comes to a new record.

When I want to input details of a new record, the main form and a subform work ok, but the third subform won't accept anything. What haven't I done, please, Experts?

 
Hi
Can you add records to the underlying query for the third subform? That is, are you sure the third subform is based on an updateable query (not an expert :))
 
Will the offending subform accept input when it is not a new record?

If no, pehaps the underlying query is not updatable

If yes, do you have .AddNew set to false on the subform?

Regards

Ken Reay
Freelance Solutions Developer
Boldon Information Systems Ltd
Website needs upgrading, but for now - UK
 
Hi Ray

Yes, the subform will take input when the record is not new.

I've looked at the query and it has the same properties as the query under the subform which accepts new record input.

It's Access2K. I don't see an .AddNew in the query properties. (Am I looking in the wrong place?)

Many thanks. And many thanks, Remou.
 
Hi Ray

Thanks for your patience and advice. With the subform in design mode, I can't find anything awry. Allow edits and that little group are all in a Yes mood. I don't find any .addnew part, and the developers handbook doesn't' help much, just offering it for coding.

Anyway, the inspection has improved things a little. When I try to input a new record, it offers one of two error messages, and then accepts the input.

Not what I need, but towards the right direction.
 
Hi Ray

Didn't stay to my advantage long. Now it won't accept any new records. I found a form property Data Entry Yes/No, but that obviously isn't the answer.

The error message now says 'You cannot add or change a record because a related record is required in table tblEmployees'.
 
Hi

"The error message now says 'You cannot add or change a record because a related record is required in table tblEmployees'."

That error has nothing to do with the (sub)form, it is being caused by your referential integity settings

You need to be aware that when you make a change to a record, or add a record, that record is not saved until you expcitly save it, or move off that record (includes closing form), so what is happening here is you have created new EE record (but not saved it) and then you are moving to the subform record and attempting to create a record to link to an EE record which does not yet exist on disc. You need to save the EE record. Difficult to advise how to do this without knowing your system, but one way would be to put code on the onenter event of the subform control, which tests if mainform is dirty, and if yes saves it, something like

If Me.dirty then
docmd.runcommand acCmdSave
End if


Regards

Ken Reay
Freelance Solutions Developer
Boldon Information Systems Ltd
Website needs upgrading, but for now - UK
 
That's marvellous of you, Ray. Will give it a try. Many thanks.
 
Ray, Sorry to trouble you again. I don't have an On Enter on the subform control. (Access2K) Well, I can't find it. Would that be the same as On Current or OnDirty?








 
Hi

Should be On Enter event in the subform CONTROL or the main form, if you have On Current, you are looking at form events, rather than control events

Regards

Ken Reay
Freelance Solutions Developer
Boldon Information Systems Ltd
Website needs upgrading, but for now - UK
 
Hi Ken
Not quite there.

I've changed the relationships around, and thanks to your direction, have the OnDirty command on both subforms.

Now when I try to enter new info on the second subform, the databaseID number appears. I can enter data, but not save. It comes up with the error message that requires a 'related field'. Cheers
 
Hi

You need to open the main form in design view, then select the subform control, you will see the On Enter Event

cannot comment on you changing relationships, as far as I could see there was nothing wrong with them.

Relationships have nothing to do with events on (sub)form, first rule of falt finding, change one thing at a time, otherwise you cannot be sure of which change caused which effect!

Regards

Ken Reay
Freelance Solutions Developer
Boldon Information Systems Ltd
Website needs upgrading, but for now - UK
 
Many thanks, Ken. (Sorry to keep calling you 'Ray'. Must be me thinking of you by both, F and SNames, at the same time.) Cheers. All noted. Thanks very for all the advice.
 
Hi Ray
I'm almost certain the problem was to do with my linking to the master field on a subform. When it began to behave, I still found I needed for 'If Me.dirty then' code.

Many thanks for yet more help from you. Much obliged.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top