PDA

View Full Version : Subform create new recordset based on mainform?



behedwin
06-28-2018, 03:46 PM
Hey

I need some help to solve a problem with creating a new record.
i have uploaded my project in both 2016 and 2003 version of access!
Please view the zip file where both files are.

to find the place i want help finding a solution to you go to:
1. open form "selectprofile_frm"
2. then doubleclick on a name in the listbox
3. go to tab "Kontrakt"
4. here you see a listbox and a button and some textboxes. when i click the button, i want to create a new record in table "contract_tbl".

I have setup things like this
Form selectprofile_frm is where i select what staff member i want to work on.
then i double click and open the proifle in form "profile_frm".
here i view data and update and add new. so far i have only come to create the "kontrakt" tab.
Under the contract tab there is a listbox and a subform.
Subform goes to "contract_frm" that display the contract information.
listbox is just to select what contract to display.

but now i want to add the feature of adding a new contract.
i get it to work just fine when not using the subform... but i want to do it in the subform.
how can this be done?

let me know if i should post screenshots or anything else.

hope someone can help
FILE:
22496

OBP
06-29-2018, 08:15 AM
I have looked at your 2003 version.
First of all I am not sure why your 2 sub tables that supply data to the Contract_Tbl are not set to One to many reletionships as the Profile_Tbl is, as they should be.
Next your Contract Form is Not a "Subform", it is a stand alone form on a separate Tab, it should be "inserted" in to the Profile form as a subform with the Master/Child links set to Master Profile_ID to Child Profile_ID_SK.
This means that any new records added to the Contract Sub Form will automatically be related to the correct Profile.

behedwin
06-29-2018, 08:35 AM
well i do not really understand....
do you think you can show me?

if i dont set child and master as i have done, the contract form wont update with the selected row in the listbox wont load to the textboxes in the contract form.

OBP
06-29-2018, 12:12 PM
That confuses me slightly as I do not see why you need the list and the form when just a form will do.
There isn't a "button" on the 2003 version, but one can be added.
At the moment I am not clear on how the "process" works, so can I ask some questions?
1. Can a contract have more than one "person" on it?
2. Does a contract have some kind of description that is currently not in your table?

OBP
06-29-2018, 12:36 PM
I have created some new forms (so that yours remain intact) to show how I would approach displaying the Contracts for a Profile.
You find a profile using the Combo (in bold) at the top of the form called New_Profile_Frm.

behedwin
06-30-2018, 12:49 AM
Thank you for your example. But that is not really what i am looking for.
In the future a contract needs to contain much more data, current columns are just a start to get the function to work.
With several more columns i can not have it all in a row like your example in your extra form.

This is the process i am envisioning.
1. User opens selectprofile_frm
2. User doubleclick a row in the listbox, selecting a person/staff to view and work with.
3. When doubleclick, profile_frm opens and display the profile of clicked person/staff.
4. In profile_frm currently i am interessted to build the tab "kontrakt" where contract_tbl data will be displayed.
5. When user click on "kontrakt" tab in profile_frm i want to first see all contracts that are connected to that person. A contract can not be connected to several person/staff. A person/staff can have several contracts.
6. It is important to me to have a listbox where the user selects the contract to bring up the full contract details in several textboxes and fields below the listbox of contract´s.
This function i have gotten to work. I can click a row in the listbox and that start to populate the textboxes below in the contract_frm (subform).

Now i am stuck on creating a new contract row in the listbox and in contract_tbl.
I want to do this in the textboxes below, click a button "create new" and all the textboxes are empty and i populate them manually to create a new contract and then saves it and a new row appears in the listbox.

why the listbox in tab Kontakt?
well i do want to see how many contracts are connected to the user fast. i do not want a combobox.
the row in the listbox should only contain the essential information of a contract, not all.
selecting the row in the listbox is easy for a user to bring up the rest of the data in one fast click.



let me know if i have missed to explain anything.
thank you very much for trying to help me!!

OBP
06-30-2018, 05:28 AM
I think this does what you want, there is a new Command Button on thr Contracts form that opens a form called "New_Contrct_Frm".

behedwin
06-30-2018, 05:53 AM
cant see what you are saying.
did you upload the correct file?

OBP
06-30-2018, 07:23 AM
Sorry, wrong file