:) Thanks in advance.
I have 4 tables (* indicates pk)
Expand|Select|Wrap|Line Numbers
- 10Company
- CompID *
- CompName
- CompDesc
Expand|Select|Wrap|Line Numbers
- 20Section
- SectCompID *
- SectID *
- SectName
- SectDesc
Expand|Select|Wrap|Line Numbers
- 30Jobs
- JobCompID *
- JobSectID *
- JobID *
- JobName
- JobDesc
Expand|Select|Wrap|Line Numbers
- 40Operations
- OpeCompID *
- OpeSectID *
- OpeJobID *
- OpeOperID *
- OpeName
- OpeDesc
I know this is not nice E-R model, but Im given ER and requested to create the maintenance Form for the Operations.
Then I have created a form:
Expand|Select|Wrap|Line Numbers
- OperationsForm
- ControlSource = 40Operations
Expand|Select|Wrap|Line Numbers
- OpeOperationTxt
- ControlSource = OpeOperID
- JobsComboBox
- ControlSource = OpeJobID
- Row Source = Select JobID, JobSectID, JobCompID from 30Jobs
- Bound Column =1
- ColumnCount = 3
- BeforeUpdate = CodeAfterColumns
- OpeJobTxt
- ControlSource = OpeJobID
- enabled, locked = No
- OpeSectionTxt
- ControlSource = OpeSectID
- enabled, locked = No
- OpeCompanyTxt
- ControlSource = OpeCompID
- enabled, locked = No
JobsComboBox.BeforeUpdate code
Expand|Select|Wrap|Line Numbers
- Me.OpeJobTxt = Me.JobsComboBox.Column(0)
- Me.OpeSectionTxt = Me.JobsComboBox.Column(1)
- Me.OpeCompanyTxt = Me.JobsComboBox.Column(2)
1.- I type a value in the OpeOperationTxt, then I select a value from JobsComboBox combo, it updates the OpeJobTxt, OpeSectionTxt, OpeCompanyTxt correctly, then if I press tab, it should create a new record in the 40Operations table, but instead, I have an error:
"You cannot add or change a record because a related record is required in 30Jobs"
I dont understand why it asks this, as the record in 30Jobs table, exists (i selected it from the combobox).
2.- Second question is, how can i stop the form from creating new records, and to do it via clicking a button
Thanks a lot.
[UPDATE]: If i delete the 1-to-N relationship, it creates the row(record) in the 40Operations table