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
272 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
  • 2
3 Comments
 
LVL 25

Accepted Solution

by:
epasquier earned 500 total points
Comment Utility
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
Comment Utility
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
Comment Utility
Thanks!
0

Featured Post

Find Ransomware Secrets With All-Source Analysis

Ransomware has become a major concern for organizations; its prevalence has grown due to past successes achieved by threat actors. While each ransomware variant is different, we’ve seen some common tactics and trends used among the authors of the malware.

Join & Write a Comment

Suggested Solutions

A lot of questions regard threads in Delphi.   One of the more specific questions is how to show progress of the thread.   Updating a progressbar from inside a thread is a mistake. A solution to this would be to send a synchronized message to the…
Have you ever had your Delphi form/application just hanging while waiting for data to load? This is the article to read if you want to learn some things about adding threads for data loading in the background. First, I'll setup a general applica…
Get a first impression of how PRTG looks and learn how it works.   This video is a short introduction to PRTG, as an initial overview or as a quick start for new PRTG users.
This video shows how to remove a single email address from the Outlook 2010 Auto Suggestion memory. NOTE: For Outlook 2016 and 2013 perform the exact same steps. Open a new email: Click the New email button in Outlook. Start typing the address: …

772 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

Need Help in Real-Time?

Connect with top rated Experts

15 Experts available now in Live!

Get 1:1 Help Now