473,385 Members | 1,356 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,385 software developers and data experts.

Error message on primary key field being null

418 256MB
I am getting error message while entering data using a sub form. Here are the details of the tables associated with this form. Basically I am trying to enter expense data.

tblECHO has these fields
Expand|Select|Wrap|Line Numbers
  1. ECHOID – Pk (auto)
  2. EchoNo – Text
  3. SubmitDate – Date/Time
  4. ReceiveDt – Date/ Time
tblMTAP
Expand|Select|Wrap|Line Numbers
  1. MTAPID – PK (auto)
  2.  VendorID – Number
  3. AccountID – Number
  4. GrantFundID – Number
  5. GrantID – Text
  6. ProjectID – Number
  7. MTAPAmount – Currency
tblSPAP
Expand|Select|Wrap|Line Numbers
  1. SPAPID – PK (auto)
  2.  VendorID – Number
  3. AccountID – Number
  4. GrantFundID – Number
  5. GrantID – Text
  6. ProjectID – Number
  7. SPAPAmount – Currency
The main form is based on tblECHO which has a two-page sub form that is based on tblMTAP and tblSPAP. As I enter data for expenses I am getting an error message

Primary Key or indexed field cannot contain a null value….

Well, I find out that as data is entered it’s updating all the primary keys except for MTAPID and SPAPID

Both the tables are related to tblECHO (join type 1, one – to – many). What can be wrong? How do I fix it?

Thanks for your help.
May 12 '09 #1
21 3680
Denburt
1,356 Expert 1GB
Both the tables are related to tblECHO (join type 1, one – to – many).
O.K. and what fields in tblECHO are used to join these tables? I don't see it.
Check that these fields are listed properly in the Link Child Fields and Link Master Fields I think that is probably the problem.

Also why are you using GrantID – Text shouldn't that be the number from the autoID in the grants table (just curious)?
May 12 '09 #2
MNNovice
418 256MB
Denburt

Both the tables have ECHOID as a FK which I forgot to mention. This the field that connects the tables.

Also, I am using GrantNo and NOT GrantID - that was an error on my part too.

Thanks.
May 12 '09 #3
Denburt
1,356 Expert 1GB
Did you check the Link Child Fields and Link Master Fields in the forms properties to make sure that EchoID is in both places? I think if you do that you should be ok.
May 12 '09 #4
MNNovice
418 256MB
Yes, I did. And they look okay. They read as for example:

Clicking on page 2 of the sub form
Source Object: sfrmSPAP
Link Child Fields: ECHOID
Link Master Fields: ECHOID

Page 1 reads as
Source Object: sfrmMTAP
Link Child Fields: ECHOID
Link Master Fields: ECHOID
May 12 '09 #5
missinglinq
3,532 Expert 2GB
You're not trying, by chance, to enter a Child record before you've entered a record in the Parent form, are you?

Linq ;0)>
May 12 '09 #6
MNNovice
418 256MB
Missingling:

No, I am not trying to do so. As a matter of fact I cannot even activate the sub form if I don't select an ID for the main form.

The field ECHOID is listed on all the three forms. In the sub form (datasheet view) I have ECHOID and MTAPID and SPAPID placed on the form header and therefore remains invisible while entering data.

Hope one of you can help me. If needed I can post the DB for a quick review. Thanks.
May 12 '09 #7
Denburt
1,356 Expert 1GB
Please feel free to upload it if you wish but I am pretty sure that from what you have said that there is a field in one of the tables that is required to have data and somehow you are overlooking it and not entering information into this field.
May 12 '09 #8
MNNovice
418 256MB
Here you go.

Please open frmECHOEnter. Thanks.
May 12 '09 #9
Denburt
1,356 Expert 1GB
ok apparently your using the Echo No. field to search for data and as such it is unbound. When you go to enter a new record into the parent "Echo" no number is recorded so that is one error that I have found. Now if you filter for an echo no. then the parent (main) form has a record and you want to add records to the subform you get the error you mentioned and it looks as if the field MTAPID is listed as your primary key but it isn't set to Autonumber so you will to fill that in manually once I did that and entered the fund bingo new record no problem. Setting the Primary key to an autonumber helps things in a lot of ways. Let me know if I missed anything
May 12 '09 #10
MNNovice
418 256MB
Denburt:

I believe using EchoNo for an Unbound control is okay because it's tied to ECHOID field of tblECHO. And actually it works just fine.

However, I really don't know how the MTAPID and SPAPID got changed to a number field as oppposed to auto. I am trying to avoid re entering data and re create a new table by exporting data to excel and then importing it back. So far no luck, somehow the first field MTAPID changes to a different data type on its own. Go figure.

I kept trying until I succeeded. I got the SPAPID taken care of because there was no data and it's working on the sub form as well as on the report. It's all working now. Thanks a lot for your time to help me out.

Thanks for checking and finding this error for me. I shall keep you posted. Your greatly needed help is much appreciated. Thanks.
May 12 '09 #11
Denburt
1,356 Expert 1GB
Glad you have it working. Just as an FYI the autonumber field can be started at a particular number but once a record has been entered that ID number can't be changed so if your importing records into that table and try to import data/numbers into that autonumber field then that is probably how it was changed. In other words you cant just assign a number to that field it is designed to do it automatically. If something gets mismatched along the way it is usually easier to let autonumber do its thing then you change the FK in the other tables to match. I hope that makes sense. ;)
May 12 '09 #12
MNNovice
418 256MB
This is what I did. I created a new table called tblMT which has the similar table structure of tblMTAP. Then I exported tblMTAP to Excel. Next I imported tblMTAP excel data and added to the new table. Deleted tblMTAP and renamed tblMT as tblMTAP. All is working okay now. Couldn't do without your help though.

New question 1: I will have several types of expenses other than AP expenses. e.g., payroll expenses, Sales tax, etc. Do you think it's okay to add more pages to frmEcho as I need? Like say, if I create tblPayroll and tblSalesTax and then create subform out of these two new table and then add them to the main form frmECHO it should be okay?

New question 2: Right now I was able to create individual reports for MTAP and SPAP for a given ECHO. I created a query and then created a report based on that query. Can I do a similar report combining these two expenses into one single report?
May 12 '09 #13
Denburt
1,356 Expert 1GB
In answer to question 1 and 2 yes that sounds fine.
May 12 '09 #14
NeoPa
32,556 Expert Mod 16PB
@MNNovice
Did someone delete the attachment?
May 13 '09 #15
Denburt
1,356 Expert 1GB
Yes she did request that. If you would like a copy I don't think she would mind though. M?
May 13 '09 #16
MNNovice
418 256MB
Definitely no problem. Please share. Thanks.
May 13 '09 #17
Denburt
1,356 Expert 1GB
M it may help if you send the most recent version and we can remove it as soon as we both get an updated copy.
May 13 '09 #18
NeoPa
32,556 Expert Mod 16PB
8-)

Sounds like you got it sorted anyway Den, but for my curiosity, and to keep my copy up-to-date.

PS. Den, you just went offline on Skype. I was hoping to catch you this evening if you're around as we haven't spoken for so long.
May 13 '09 #19
MNNovice
418 256MB
NeoPa / Den:

Here is the latest version. Thanks for all your help.

M
May 14 '09 #20
NeoPa
32,556 Expert Mod 16PB
Thanks M.

I have it now. You can remove it when you're done Den.
May 14 '09 #21
Denburt
1,356 Expert 1GB
Got it. I will try and take a look at this in a little while, things are a little busy over here.
May 14 '09 #22

Sign in to post your reply or Sign up for a free account.

Similar topics

2
by: affiori | last post by:
Can anybody shed some light on this error? When I try to create tables for the database for phpnuke using the supplied sql file when i get toe "nuke_contactbook" table, I get back this: =========...
0
by: Morten Gulbrandsen | last post by:
C:\mysql\bin>mysql -u elmasri -pnavathe company Welcome to the MySQL monitor. Commands end with ; or \g. Your MySQL connection id is 29 to server version: 4.1.0-alpha-max-debug Type...
0
by: Morten Gulbrandsen | last post by:
mysql> USE company; Database changed mysql> mysql> DROP TABLE IF EXISTS EMPLOYEE; -------------- DROP TABLE IF EXISTS EMPLOYEE -------------- Query OK, 0 rows affected (0.00 sec)
14
by: Abhi | last post by:
FYI: This message is for the benefit of MS Access Community. I found that this prblem has been encounterd by many but there is hardly any place where a complete solution is posted. So I thought...
14
by: Tom | last post by:
Using AccessXP in 2000 mode. I have the following tables --- TblLocation LocationID PropertyID StateID CountyID CityID
1
by: Jeremy Ames | last post by:
I have a datagrid that updates the table using a stored procedure. The stored procedure is confirmed to complete correctly, yet the sql data adapter is returning an error that my application is...
13
by: dbuchanan | last post by:
Hello, Here is the error message; ---------------------------- Exception Message: ForeignKeyConstraint Lkp_tbl040Cmpt_lkp302SensorType requires the child key values (5) to exist in the...
0
by: David | last post by:
This is a .net 1.1 question. I am attempting to load and process an XML file (see below) with XmlDocument. I can load the file: XmlDocument doc = new XmlDocument(); doc.Load("dump.xml"); ...
2
hyperpau
by: hyperpau | last post by:
Before anything else, I am not a very technical expert when it comes to VBA coding. I learned most of what I know by the excellent Access/VBA forum from bytes.com (formerly thescripts.com). Ergo, I...
0
hyperpau
by: hyperpau | last post by:
Before anything else, I am not a very technical expert when it comes to VBA coding. I learned most of what I know by the excellent Access/VBA forum from bytes.com (formerly thescripts.com). Ergo, I...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.