Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
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
Medium Priority
?
282 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 2000 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: IP Lookup

Get more info about an IP address or domain name, such as organization, abuse contacts and geolocation.

One of a set of tools we are providing to everyone 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

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…
Introduction I have seen many questions in this Delphi topic area where queries in threads are needed or suggested. I know bumped into a similar need. This article will address some of the concepts when dealing with a multithreaded delphi database…
In this brief tutorial Pawel from AdRem Software explains how you can quickly find out which services are running on your network, or what are the IP addresses of servers responsible for each service. Software used is freeware NetCrunch Tools (https…
Add bar graphs to Access queries using Unicode block characters. Graphs appear on every record in the color you want. Give life to numbers. Hopes this gives you ideas on visualizing your data in new ways ~ Create a calculated field in a query: …
Suggested Courses

670 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