473,385 Members | 1,925 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.

Data Entry Form - Index/Primary key null value

10
I have a form to create a new record for a training course. The form is based on one table that has 4 keys set to primary key.

The first combo box on the form allows selection of the course POP code and this then fills details on 2 list boxs for course module code and description. The course section can then be selected from another combo box (filtered by the value in the first combo box) . Finally the course session name is entered manually. These 4 make a primary key. (POPCode, ModuleCode, Section, Session).

Further details of trainer etc are also filled in a similar manner.

When all of the controls on the form are full (I have ensured they meet referential integrity rules) i still get an "Index/Primary key cannot contain null value" message. I do not understand why as all of the controls have control sources set to the underlying table adn all have a value assigned. Any help is appreciated...
Thanks
Oct 23 '06 #1
12 4490
MMcCarthy
14,534 Expert Mod 8TB
I can't be sure because I've never set up a table with four primary keys but I imagine Access is having some problems with it. Why not just add a key 'ID' set to autonumber and make it the primary key.



I have a form to create a new record for a training course. The form is based on one table that has 4 keys set to primary key.

The first combo box on the form allows selection of the course POP code and this then fills details on 2 list boxs for course module code and description. The course section can then be selected from another combo box (filtered by the value in the first combo box) . Finally the course session name is entered manually. These 4 make a primary key. (POPCode, ModuleCode, Section, Session).

Further details of trainer etc are also filled in a similar manner.

When all of the controls on the form are full (I have ensured they meet referential integrity rules) i still get an "Index/Primary key cannot contain null value" message. I do not understand why as all of the controls have control sources set to the underlying table adn all have a value assigned. Any help is appreciated...
Thanks
Oct 23 '06 #2
MMcCarthy
14,534 Expert Mod 8TB
By the way you can still set the other keys to required if that's what you're worried about but they shouldn't need to be part of the primary key.



I can't be sure because I've never set up a table with four primary keys but I imagine Access is having some problems with it. Why not just add a key 'ID' set to autonumber and make it the primary key.
Oct 23 '06 #3
Aidan
10
thanks,
true that it was not needed, it works fine with just 1 primary key.
cheers
Oct 25 '06 #4
Aidan
10
I have a form to create a new record for a training course.
The first combo box on the form allows selection of the course POP code and this then fills details on 2 list boxs for course module code and description.

Problem: the 2 controls above are not taking the requery-ed value through to the table. The proper data is displayed on the form but when i look at the table being updated, the data is not present. If i (mouse) click on the controls then the value is passed to the table, but if i tab through it, it still isnt passed to the table!
Is there a way to simulate the controls being clicked?

very confused.....
Oct 25 '06 #5
MMcCarthy
14,534 Expert Mod 8TB
Firstly

What is the Control Source property of each of these fields set to?

regardless of any action if the control source is set to the field in the table then the field should update.
Oct 25 '06 #6
Aidan
10
the control source for each control is set to the appropriate field of the table.
Also, the bound column is set to 0.
The value that is selected is from an SQL statement in the controls row source. This is requery-ed after selection of the value in the first combo.
baffling!





Firstly

What is the Control Source property of each of these fields set to?

regardless of any action if the control source is set to the field in the table then the field should update.
Oct 26 '06 #7
MMcCarthy
14,534 Expert Mod 8TB

Also, the bound column is set to 0.
The bound column needs to be set to 1. The first column is only refered to a 0 when its being used programmatically.

e.g. Me.combobox.Column(0)
Oct 26 '06 #8
Aidan
10
thanks, but it still doesnt change things, when i arrow to the next record after entering details, the values in the controls that dont update stay on the form - mean anything to you?
Thanks again,
Aidan
Oct 27 '06 #9
MMcCarthy
14,534 Expert Mod 8TB
What code are you using on the combo box and in what event did you put it.

Is there any coded event on the two text boxes.
Oct 27 '06 #10
Aidan
10
Hi,
sorry i have been away for a few days.
there is a simple code on the combo to requery the 2 controls that i am having the problem with, its placed 'OnChange':

Private Sub POPCode_Change()
Me.ModuleDescription.Requery
Me.ModuleCode.Requery
End Sub

You think this could be thew problem?
thanks
Aidan
Nov 1 '06 #11
MMcCarthy
14,534 Expert Mod 8TB
Change to the AfterUpdate event and see if that makes a difference.

Expand|Select|Wrap|Line Numbers
  1.  
  2. Private Sub POPCode_AfterUpdate()
  3. Me.ModuleDescription.Requery
  4. Me.ModuleCode.Requery
  5. End Sub
  6.  
  7.  
Nov 1 '06 #12
Aidan
10
No help either...this is the row source of one of the controls being requeryed:

SELECT tblTrainingModules.ModuleCode FROM tblTrainingModules WHERE tblTrainingModules.POPCode = Forms!frmTrainingSessions1.POPCode

make any difference?
Nov 1 '06 #13

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

Similar topics

10
by: heromull | last post by:
We have an asp.net app with about 200 data entry forms. Customers may enter data into any number of forms. Each form's data is persisted in a corresponding sql table. When data entry is...
4
by: Doslil | last post by:
I have a form which has a subform.In the main form I have only one field (this is a drop down list and has a query attached to it) which selects empno,Name from the EmployeeInformation table. ...
4
by: Thomas Paul Diffenbach | last post by:
Can anyone point me to an open source library of /statically allocated/ data structures? I'm writing some code that would benefit from trees, preferably self balancing, but on an embedded system...
0
by: Jerry | last post by:
Below is ALL the code for all the databases... Here's the problem: I callup the aspx file in IE and the form comes up just fine. When I select a person to update, I get the subject error. ...
2
by: RottNKorpse | last post by:
Well I am trying to make an admin section to allow my other admins of my site able to add content to my mysql database without giving them phpmyadmin access and without teaching them out to use it as...
0
by: David Linsin | last post by:
I created a simple test case to reproduce the problem (also check Bug #15500): import java.sql.Connection; import java.sql.DriverManager; import java.sql.ResultSet; import java.sql.Statement;...
4
by: so many sites so little time | last post by:
ok so i am having problems if you look at the script below you will see that it the query has 4 values to insert but the actual values only contain title entry and now() for the date. well i have...
1
by: Maria DiGiano | last post by:
I am using Access to organize data from a survey which uses a Likert scale to measure response- the scale is 3 points- "I agree", "I don't know" and "I disagree". The numerical value of each...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
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:
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
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
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...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...

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.