469,586 Members | 2,195 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 469,586 developers. It's quick & easy.

error when selecting data from the dropdown list

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.

The sub form stores the time sheet data for each employee.When I am
able to do the timesheet data entry for the first record.But when I
select the second employee from the dropdown list and click on the
subform for entering the timesheet data, it says " The changes you
requested to the table were not succesful because they could create
duplicate values in the index,primary key or relationship.Change the
data in the field or fields that contain duplicate data, remove the
index or redifine the index to permit duplicate entries and try again"

Well,I am able to do data entry in the datasheet.Can anyone please
help me with solving this problem

Thanks
Nov 12 '05 #1
4 1823
Yout question is a little short or information but....

I should have thought that the main form should be bound to the Employee
Table with possibly the name showing for verification, and fine, use the
dropdown to select the employee.

I also guess that the time sheet subform is based on a table with
TimeSheetID AutoNumber Key
EmployeeID Long Indexed Duplicates allowed
TimeOn, TimeOff, etc

Assuming that the Link Child & Master Fields is EmployeeID, there should be
no problem.
Are you sure that the EmployeeID in the TimeSheet table allows duplicates?

Phil

"Doslil" <do****@hotmail.com> wrote in message
news:c6************************@posting.google.com ...
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.

The sub form stores the time sheet data for each employee.When I am
able to do the timesheet data entry for the first record.But when I
select the second employee from the dropdown list and click on the
subform for entering the timesheet data, it says " The changes you
requested to the table were not succesful because they could create
duplicate values in the index,primary key or relationship.Change the
data in the field or fields that contain duplicate data, remove the
index or redifine the index to permit duplicate entries and try again"

Well,I am able to do data entry in the datasheet.Can anyone please
help me with solving this problem

Thanks

Nov 12 '05 #2

yes,

The employee number in the child table allows duplicates.

The structure is like this.

EmployeeInformation (master table)

Employeenumber(PK)
FirstName
LastName
SSNumber
Title
Position

TimeSheet(child Table)
EmployeeNumber(linked to master table,allows duplicates)
date
day
TimeIN
TimeOut
All I have done in the form is attached a query to the employeenumber
(this is a dropdown list)selecting the employee number from the master
table.I see the record selector in the form is not moving to the next
record.I have not attached any code other than the query.

I hope you'll get a clear picture of what I have done :)
Let me know if you need further clarification
regards
*** Sent via Developersdex http://www.developersdex.com ***
Don't just participate in USENET...get rewarded for it!
Nov 12 '05 #3
Lets call the dropdown box FindEmployee.
What normally happens is that your dropdown list is based on a query like
"SELECT Lastname, FirstName, EmployeeNumber FROM EmployeeInformation ORDER
BY LastName, FirstName;"
Make sure that it is unbound, there are 3 columns, the column widths are
something like 4cm;4cm;0cm and the bound column is column 3 (the emplyee
number)

I am assuming the EmployeeNumber is an autonumber.

On the main form I am assuming you have all the employee details

On the AfterUpdate event you need
DoCmd.GotoControl "EmployeeNumber"
DoCmd.FindRecord FindEmployee

This should make the main record of the form the selected employee
As I said before the LinkMasterFields and the LinkSlaveFilds of the subform
should both be set to EmployeeNumber

Otherwise I can offer no help

Phil
"Dos Lil" <do****@hotmail.com> wrote in message
news:3f*********************@news.frii.net...

yes,

The employee number in the child table allows duplicates.

The structure is like this.

EmployeeInformation (master table)

Employeenumber(PK)
FirstName
LastName
SSNumber
Title
Position

TimeSheet(child Table)
EmployeeNumber(linked to master table,allows duplicates)
date
day
TimeIN
TimeOut
All I have done in the form is attached a query to the employeenumber
(this is a dropdown list)selecting the employee number from the master
table.I see the record selector in the form is not moving to the next
record.I have not attached any code other than the query.

I hope you'll get a clear picture of what I have done :)
Let me know if you need further clarification
regards
*** Sent via Developersdex http://www.developersdex.com ***
Don't just participate in USENET...get rewarded for it!

Nov 12 '05 #4
Thanks phil,

Fixed the problem by adding an unbound combo list and an unbound subform
with a simple select query

regards
Dos lil

*** Sent via Developersdex http://www.developersdex.com ***
Don't just participate in USENET...get rewarded for it!
Nov 12 '05 #5

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

5 posts views Thread by izco | last post: by
2 posts views Thread by =?Utf-8?B?S3Jpc2huYQ==?= | last post: by
2 posts views Thread by JJ297 | last post: by
reply views Thread by suresh191 | last post: by
4 posts views Thread by guiromero | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.