How to enter a record in a table via a subform

nianko

Registered User.
Local time
Yesterday, 22:43
Joined
Aug 17, 2010
Messages
21
Hi forum,

I have a main form with several tabs. Each of those tab has one subform linked to its related table. I would like to be able to enter a new item in one of the table via the subform and I used the following code:

Code:
Private Sub Form_Load()
DoCmd.GoToRecord acDataForm, Me.tblEmetteurs_AddItems_subform.Name, acNewRec
End Sub
I obtain a msg error from the debogger: "Compile error: Method or data member not found." :confused:

Do you have an idea?

Thx
 
If the sub-form's parent record isn't saved yet and particularly if you have declared a formal relationship with relational integrity, you might not be able to do this. The child cannot save a record until its parent has the corresponding parent record.
 
Hi,

Thx for the answer. I must admit I'm a bit confused now. I do have a main form, but that form only contains a tab control (with 6 tabs) and on each of those tab I have a subform (6 subform). The main form is just a blank page that contains the tab.

Maybe I'm wrong altogether with that form?

N
 
Last edited:
Hello,

It's purely because I don't want to have 6 buttons to load 6 different forms to add 6 types of items. I'dd rather have one AddItem form (blank) with 6 subforms on each of the 6 tabs.

I've been blocked for quite a while on this now and I cannot move on because I don't know how to refer to the subform...
 
How about describing What the business and associated rules are in 5 or 6 sentences? We only know what you tell us and you haven't said much about WHAT-- you have told us HOW you want to do something.

Here's a sample:
ZYX Laboratories requires an employee tracking database. They want to track information about employees, the employee's job history, and their certifications. Employee information includes first name, middle initial, last name, social security number, address, city, state, zip, home phone, cell phone, email address. Job history would include job title, job description, pay grade, pay range, salary, and date of promotion. For certifications, they want certification type and date achieved.

An employee can have multiple jobs over time, (ie, Analyst, Sr. Analyst, QA Administrator). Employees can also earn certifications necessary for their job.

The better we understand your situation, the more focused any comments and suggestions.
 
Hi,

The database has 3 important tables (the rest are just reference tables):
- A table that contains names of issuers (companies)
- A table that contains bonds issued by those companies (or not if they are listed as potential issuers but have not issued anything)
- A table for funds that contain individual bond issues

I would like (instead of having 3 forms to add an issuer / bon/ fund, then3 forms to modify them, then 3 forms to delete them) a general "Add form" on which I have a tab to add an Issuer, then a tabl to add a bond issue, then a tab to add a fund. THe 3 other tabs are less relevant.

I hope this does make sense.

my main form is called "frmAddItems"
my control (the 6 tabs) was renamed "ctrAddItems"
the subform in the 1st tab (X) is called "tblX_AddItems_subform"

I've tried various unsuccessful lines of code:

Code:
 Private Sub Form_Load()
DoCmd.GoToRecord acDataForm, Me.frmAddItems.ctrAddItems.tblX_AddItems_subform.Name, acNewRec End Sub
Code:
Private Sub Form_Load()
Me.ctrAddItems.SetFocus DoCmd.RunCommand acCmdRecordsGoToNew End Sub
But nothing works...:banghead:
 

Users who are viewing this thread

Back
Top Bottom