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

Saving problem

Status
Not open for further replies.

Diezz

Technical User
Dec 24, 2004
61
NL
Hello, i have 2 tables

Employees (IdEmp, NameEmp, PasswordEMP) and
Calls(IdEmp, NoCall, problem, description, case)

Case take up values from "Yes", "No", "Suivi","Error".

I've created a log on form that works very well (frm logon), using a combo box(cboEmployee)and a field where one can insert the password, and another form that takes all the fields from table "Calls".

When i receive a call i'll note it in this form (frmCalls).

Also IdEMP from the form Calls is set up as = forms!frmLogon!cboemployees.column(0).

When i press the buton "save" in order to save my record it gaves me an error message : You cannot add or change a record because a related record is required in table "Employees". However this happens only the second time when i press the second time on "save", the first times it saves the record, and refresh the form to the default values, and when i change them and hit again save it gaves me the error.

Anyone knows what is the problem?
 
I would guess that [tt]forms!frmLogon!cboemployees.column(0)[/tt] has gone missing in some way. The reason for the message is that 'Calls' is related to 'Employees' and referential integrity is enforced, so an employee number is required in the calls table.
 
can i somehow keep the value? or what would be most suited to do?
 
I think you should find out why it has gone missing. Has frmLogon been closed? If so, keeping the form open and hidden may suit. It may also be possible to set the Control Source for IdEMP or the Default Value from the combobox or use OpenArgs. It all depends on how you want it to work.
 
Now it works but i have to select the user first. Before i had it by default = column(0) and it worked, however it wasn't bound to the table:), i think that was the problem.

I'll try to put again the value par default and i'll check if it works now, that it's bound.
 
I did some changes and now it gaves me another error message. He can't perform the saving procedure because the field it's empty, however the field it's not null.
 
Perhaps it is a zero-length string? Have you tried:

[tt]If Trim(txtText & " ")="" Then[/tt]

Adding a space to the field, trimming and then checking means that the field will be equal to "" if it is null, a zero-length string or just a lot of spaces.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top