Disable add ing new record to subform

steve87bg

Registered User.
Local time
Today, 10:12
Joined
Jan 14, 2013
Messages
19
I have main forn and on open event i have code

Code:
DoCmd.GoToRecord , , acNewRec

Now i also have subform in my main form. Is there any solution to open only main form in new record and my subform to retain value that it has? Or is there any solution to textbox in my subform go to first record in subform on open event
 
As for answering your subject line, there is a form property Me.AllowAdditions where you may disable Adding records. This is found on the Data tab of the Form's Properties box.

As for the relationships between the parent and sub form, I will leave that to others to address as no doubt my use of Subforms is very different than what you are dealing with. The way I deal with them, there is no direct correlation between the datasources of parent / sub... I see that as the whole reason to deal with subforms... in order to obtain a distinct datasource.
 
You would need to remove the child/parent references in the subform in order for it to keep the data in it while adding a new record - but not sure why you would want to do this?
 
It sounds like you want all new main records to have the same default values that are in your current subform? Is that what you are trying to accomplish?
 
It sounds like you want all new main records to have the same default values that are in your current subform? Is that what you are trying to accomplish?

My subform have a value that is neaded for some others values in my main form.

I have two tables "Unos" and "Bod". I made query that gave me a value from "Bod" table for column "Vrednost" where id =1. I made a subform based on that value. In my other table wich is my main form i also have "Vrednost" column.

I want if user in main form change value "Vrednost", that value "Vrednost" in subform also change. But when user open form or go to new record that textbox in main form("Vrednost") have value from my subform field "Vrednost". I hope someone understood me :banghead:
 
It sounds like you are making use of the sub-form incorrectly. If you based your subform on a query where ID = 1 then you are always only going to get that one record in your subform. It won't change. Plus if you want it to change the way you are describing, you will always only have one record in the subform table.

Base your subform on the Vrednost table by itself, not the query. Then in the subform object properties on your main form, make sure you put the Parent/Child fields in as ID.

Your table structures probably are not correct either. You should have
BOD Table
ID should be primary key

in Vrednost table
You should have Vrednost with it's own primary key and ID should be a foreign key.
VrednostID primary key,
ID (linked to BOD table)

Also, I would avoid using just ID as your field name.
 

Users who are viewing this thread

Back
Top Bottom