Solved

Make blank cell in Delphi "You cannot add or change a record because a related record is required..."

Posted on 2011-09-10
3
279 Views
Last Modified: 2012-05-12
I'm using Delphi with an MS Access Database.

I have two tables

Kid Names
==========
John
Mary
Paul

Class List
===========
Grade | Name
-------  ---------
Grade 2 | John
Grade 7 |
Grade 3 | Mary

Now for some reason, in Delphi, once a cell is modified, it will not let me change it to a BLANK cell again.

Yes these two tables are in a relationship.

But Delphi is OK with the cell being a blank cell--BEFORE a change is propagated. But once you propagate a change, and try to go blank again, you get the error message in the Title of this thread.

This is obviously because, there is no blank cells in table KIDS NAMES.

So how do i find a way to specify that I do not wish to assign a kid to GRADE 7 at this time. e.g. i want to leave it blank for now...?
0
Comment
Question by:bobbysdog
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
3 Comments
 
LVL 25

Accepted Solution

by:
epasquier earned 500 total points
ID: 36517459
you don't want blank (empty string) but NULL value
something like this

procedure SetClassKid(KidName:String);
Var
 fldName:TField;
begin
 fldName:=tblClassList.FieldByName('NAME');
 if KidName<>''
  Then fldName.Value:=KidName
  Else fldName.Clear;  // set this field to NULL
end;
0
 

Author Comment

by:bobbysdog
ID: 36517591
Yaaaay

Right - the solution was to make it NULL

I used this line to do it:

ADOTable1.FieldValues['KidsName'] := Null;

Open in new window

0
 

Author Closing Comment

by:bobbysdog
ID: 36517593
Thanks!
0

Featured Post

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

In this tutorial I will show you how to use the Windows Speech API in Delphi. I will only cover basic functions such as text to speech and controlling the speed of the speech. SAPI Installation First you need to install the SAPI type library, th…
Creating an auto free TStringList The TStringList is a basic and frequently used object in Delphi. On many occasions, you may want to create a temporary list, process some items in the list and be done with the list. In such cases, you have to…
I've attached the XLSM Excel spreadsheet I used in the video and also text files containing the macros used below. https://filedb.experts-exchange.com/incoming/2017/03_w12/1151775/Permutations.txt https://filedb.experts-exchange.com/incoming/201…
Attackers love to prey on accounts that have privileges. Reducing privileged accounts and protecting privileged accounts therefore is paramount. Users, groups, and service accounts need to be protected to help protect the entire Active Directory …

751 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question