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
278 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
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

Free Tool: Path Explorer

An intuitive utility to help find the CSS path to UI elements on a webpage. These paths are used frequently in a variety of front-end development and QA automation tasks.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Why can't I create any project with my delphi EXE file? 6 43
DBGrid or StringGrid ? 6 119
Delphi: barcode reading on android platform 1 66
IP without any Dots 1 49
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…
Hello everybody This Article will show you how to validate number with TEdit control, What's the TEdit control? TEdit is a standard Windows edit control on a form, it allows to user to write, read and copy/paste single line of text. Usua…
With Secure Portal Encryption, the recipient is sent a link to their email address directing them to the email laundry delivery page. From there, the recipient will be required to enter a user name and password to enter the page. Once the recipient …
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…

679 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